In Files

Parent

Files

Bullshit::ChiSquareDistribution

This class is used to compute the Chi-Square Distribution.

Attributes

df[R]

(Not documented)

Public Class Methods

new(df) click to toggle source

Creates a ChiSquareDistribution for df degrees of freedom.

# File lib/bullshit.rb, line 910
    def initialize(df)
      @df = df
      @df_half = @df / 2.0
    end

Public Instance Methods

inverse_probability(p) click to toggle source

Returns the inverse cumulative probability value of the NormalDistribution for the probability p.

# File lib/bullshit.rb, line 929
    def inverse_probability(p)
      case
      when p <= 0, p >= 1
        0.0
      else
        begin
          bisect = NewtonBisection.new { |x| probability(x) - p }
          range = bisect.bracket 0.5..10
          bisect.solve(range, 1_000_000)
        rescue
          0 / 0.0
        end
      end
    end
probability(x) click to toggle source

Returns the cumulative probability (p-value) of the ChiSquareDistribution for the value x.

# File lib/bullshit.rb, line 919
    def probability(x)
      if x < 0
        0.0
      else
        gammaP_regularized(x / 2, @df_half)
      end
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.