Chi Squared Distribution Table - estebanz01/ruby-statistics GitHub Wiki
This class holds the distribution table for the Chi Squared distribution.
It returns the alpha values that are represented in the chi squared distribution table:
irb(main):001> RubyStatistics::Distribution::Tables::ChiSquared.alpha_values
=> [0.995, 0.99, 0.975, 0.95, 0.9, 0.1, 0.05, 0.025, 0.01, 0.005]
It returns true if the specified alpha value is within the list of alpha values that are represented in the chi squared distribution table:
irb(main):002> RubyStatistics::Distribution::Tables::ChiSquared.valid_alpha?(0.1)
=> true
irb(main):003> RubyStatistics::Distribution::Tables::ChiSquared.valid_alpha?(0.2)
=> false
It returns the critical values and its degrees of freedom for the specified alpha value that is represented in the chi square distribution table. If the value is not known, it raises an error.
irb(main):004> RubyStatistics::Distribution::Tables::ChiSquared.alpha_column(0.02)
lib/ruby-statistics/distribution/tables/chi_squared.rb:76:in `alpha_column': Undefined alpha value. (RuntimeError)
from (irb):4:in `<main>'
from <internal:kernel>:187:in `loop'
from bin/console:14:in `<main>'
irb(main):005> RubyStatistics::Distribution::Tables::ChiSquared.alpha_column(0.01)
=>
[{:df=>1, :critical_value=>6.635},
{:df=>2, :critical_value=>9.21},
{:df=>3, :critical_value=>11.345},
{:df=>4, :critical_value=>13.277},
{:df=>5, :critical_value=>15.086},
{:df=>6, :critical_value=>16.812},
{:df=>7, :critical_value=>18.475},
{:df=>8, :critical_value=>20.09},
{:df=>9, :critical_value=>21.666},
{:df=>10, :critical_value=>23.209},
{:df=>11, :critical_value=>24.725},
{:df=>12, :critical_value=>26.217},
{:df=>13, :critical_value=>27.688},
{:df=>14, :critical_value=>29.141},
{:df=>15, :critical_value=>30.578},
{:df=>16, :critical_value=>32.0},
{:df=>17, :critical_value=>33.409},
{:df=>18, :critical_value=>34.805},
{:df=>19, :critical_value=>36.191},
{:df=>20, :critical_value=>37.566},
{:df=>21, :critical_value=>38.932},
{:df=>22, :critical_value=>40.289},
{:df=>23, :critical_value=>41.638},
{:df=>24, :critical_value=>42.98},
{:df=>25, :critical_value=>44.314},
{:df=>26, :critical_value=>45.642},
{:df=>27, :critical_value=>46.963},
{:df=>28, :critical_value=>48.278},
{:df=>29, :critical_value=>49.588},
{:df=>30, :critical_value=>50.892},
{:df=>40, :critical_value=>63.691},
{:df=>50, :critical_value=>76.154},
{:df=>60, :critical_value=>88.379},
{:df=>70, :critical_value=>100.425},
{:df=>80, :critical_value=>112.329},
{:df=>90, :critical_value=>124.116},
{:df=>100, :critical_value=>135.807}]