Module: Rust::Probabilities
- Defined in:
- lib/rust/stats/probabilities.rb
Overview
Module that contains utilities for handling random variables.
Instance Method Summary collapse
-
#E(v) ⇒ Object
Computes the expected value of the random variable
v
. -
#P(v) ⇒ Object
Computes the probability of the random variable
v
.
Instance Method Details
#E(v) ⇒ Object
Computes the expected value of the random variable v
.
310 311 312 313 314 315 316 |
# File 'lib/rust/stats/probabilities.rb', line 310 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
Computes the probability of the random variable v
.
298 299 300 301 302 303 304 305 |
# File 'lib/rust/stats/probabilities.rb', line 298 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 |