Object
This class is used to compute the Normal Distribution.
Creates a NormalDistribution instance for the values mu and sigma.
# File lib/bullshit.rb, line 869 def initialize(mu = 0.0, sigma = 1.0) @mu, @sigma = mu.to_f, sigma.to_f end
Returns the inverse cumulative probability value of the NormalDistribution for the probability p.
# File lib/bullshit.rb, line 885 def inverse_probability(p) case when p <= 0 -1 / 0.0 when p >= 1 1 / 0.0 when p == 0.5 # This is a bit sloppy, maybe improve this later. @mu else begin NewtonBisection.new { |x| probability(x) - p }.solve(nil, 1_000_000) rescue 0 / 0.0 end end end
Returns the cumulative probability (p-value) of the NormalDistribution for the value x.
# File lib/bullshit.rb, line 879 def probability(x) 0.5 * (1 + erf((x - @mu) / (@sigma * ROOT2))) end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.