Closed agarie closed 9 years ago
Oh well...
require 'distribution'
y = 0.975
n = 5
m = 4.189092917592713
# Everything OK for now...
Distribution::F::Ruby_.p_value(y, n, 4) # => 9.364409999999994
GSL::Cdf.fdist_Pinv(y, n, 4) # => 9.36447081580829
Distribution::F::Ruby_.p_value(y, n, m) # => NoMethodError: undefined method `even?' for 4.189092917592713:Float
GSL::Cdf.fdist_Pinv(y, n, m) # => 8.80568714984652
After fixing the above error, i.e. removing the wrong calls to #even?
and #odd?
:
>> Distribution::F::Ruby_.p_value(y, n, m) # => 20.784610000000026
>> GSL::Cdf.fdist_Pinv(y, n, m) # => 8.80568714984652
Alright, so there is something wrong with the implementation of Ruby_#p_value
, Ruby_#pf
, Ruby#pfsub
or Ruby_#q_f
. I just don't know why. I'll try to find a reference before starting to review what is wrong there. :(
I'm still not finished, I need to make sure these changes fixes what is being tested in Statsample. This fixes the tests introduced in #9. Let's hope Travis thinks the same. :)
There's another big problem: these functions aren't documented. Most of Distribution is like that, really, but let's take one step at a time. For example, some references for the approximations in
pf
,pfsub
andq_f
would be helpful while debugging.