Class: Statistical::Distribution::Bernoulli
- Defined in:
- lib/statistical/distribution/bernoulli.rb
Overview
Note:
The states used to represent success & failure must be Numeric. Using it on generic state lables can cause strange outcomes!
Note:
state_failure < state_sucesss, for the sake of sanity.
This is a convenience class implemented for syntactic sugar. ‘TwoPoint.new(p)` already mimics and is infact the behaviour of this class
Instance Attribute Summary collapse
-
#p ⇒ Float
readonly
probability of the success state (= 1).
-
#q ⇒ Float
readonly
probability of the failure state (= 0).
Attributes inherited from TwoPoint
Instance Method Summary collapse
-
#initialize(prob_success = 0.5) ⇒ Bernoulli
constructor
Returns a new instance of the Bernoulli distribution.
Methods inherited from TwoPoint
#cdf, #mean, #pdf, #quantile, #variance
Constructor Details
#initialize(prob_success = 0.5) ⇒ Bernoulli
Returns a new instance of the Bernoulli distribution
23 24 25 26 |
# File 'lib/statistical/distribution/bernoulli.rb', line 23 def initialize(prob_success = 0.5) super(prob_success) self end |
Instance Attribute Details
#p ⇒ Float (readonly)
probability of the success state (= 1)
16 17 18 |
# File 'lib/statistical/distribution/bernoulli.rb', line 16 def p @p end |
#q ⇒ Float (readonly)
probability of the failure state (= 0)
16 17 18 |
# File 'lib/statistical/distribution/bernoulli.rb', line 16 def q @q end |