Module: Rust::Probabilities

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

Overview

Module that contains utilities for handling random variables.

Instance Method Summary collapse

Instance Method Details

#E(v) ⇒ Object

Computes the expected value of the random variable v.



331
332
333
334
335
336
337
# File 'lib/rust/stats/probabilities.rb', line 331

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.



319
320
321
322
323
324
325
326
# File 'lib/rust/stats/probabilities.rb', line 319

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