Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chi-square q_chi2 range violation #21

Open
apetrov opened this issue Feb 5, 2016 · 2 comments
Open

Chi-square q_chi2 range violation #21

apetrov opened this issue Feb 5, 2016 · 2 comments

Comments

@apetrov
Copy link

apetrov commented Feb 5, 2016

2.1.6 :112 > Distribution::ChiSquare.q_chi2(4000, 1487)
=> 1.1715358426793223
2.1.6 :113 > Distribution::ChiSquare.q_chi2(4000, 1488)
=> 1.287980205519492
2.1.6 :114 > Distribution::ChiSquare.q_chi2(4000, 1489)
=> 1.0610471112556463
2.1.6 :115 > Distribution::ChiSquare.q_chi2(4000, 1490)
=> 1.7505434400435371
2.1.6 :116 > Distribution::ChiSquare.q_chi2(4000, 1491)
=> 0.0
2.1.6 :117 > Distribution::ChiSquare.q_chi2(4000, 1492)
=> 0.0

it is expected Distribution::ChiSquare.q_chi2 to be within [0..1] range

@envp
Copy link
Contributor

envp commented Feb 7, 2016

I can see the same issue in SciRuby's master branch. Great catch!

Please add a pull request with tests for this to SciRuby's master branch

~/workspace (master) $ bundle exec irb
2.2.1 :001 > require 'distribution'                                                                                                                                                                                                        
 => true 
2.2.1 :002 > Distribution::ChiSquare.q_chi2(4000, 1487)
 => 1.1715358426793223 
2.2.1 :003 > Distribution::ChiSquare.q_chi2(4000, 1488)
 => 1.287980205519492 
2.2.1 :004 > Distribution::ChiSquare.q_chi2(4000, 1489)
 => 1.0610471112556463 
2.2.1 :005 > Distribution::ChiSquare.q_chi2(4000, 1490)
 => 1.7505434400435371 
2.2.1 :006 > Distribution::ChiSquare.q_chi2(4000, 1491)
 => 0.0 
2.2.1 :007 > Distribution::ChiSquare.q_chi2(4000, 1492)
 => 0.0 

@oliver-czulo
Copy link

Might it be the bug is around still? Here is what I get:

irb(main):010:0> Distribution::ChiSquare.q_chi2(1, 69)
=> 0.0
irb(main):011:0> Distribution::ChiSquare.q_chi2(1, 68)
=> 0.0
irb(main):012:0> Distribution::ChiSquare.q_chi2(1, 67)
=> 0.0
irb(main):013:0> Distribution::ChiSquare.q_chi2(1, 66)
=> 4.440892098500626e-16

If there is any branch that solves this, would be greatful for a pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants