Module: Rust::Probabilities

Defined in:
lib/rust/stats/probabilities.rb

Instance Method Summary collapse

Instance Method Details

#E(v) ⇒ Object



205
206
207
208
209
210
211
# File 'lib/rust/stats/probabilities.rb', line 205

def E(v)
    if v.is_a? RandomVariableSlice
        return v.expected
    else
        raise "Cannot compute the expected value of a #{v.class}"
    end
end

#P(v) ⇒ Object



196
197
198
199
200
201
202
203
# File 'lib/rust/stats/probabilities.rb', line 196

def P(v)
    if v.is_a? RandomVariableSlice
        raise "Cannot compute the probability of a random variable" if v.is_a? RandomVariable
        return v.probability
    else
        raise "Cannot compute the expected value of a #{v.class}"
    end
end