help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with chisquare_inv/chi2inv


From: A. Scottedward Hodel
Subject: Problem with chisquare_inv/chi2inv
Date: Wed, 19 Sep 2007 09:43:19 -0500

The behavior of chisquare_inv (deprecated) and chi2inv appears to have changed between 2.9.12 and 2.9.13; I initially thought that the change is a result of a mild change to gaminv.m between octave 2.9.12 and 2.9.13 (diff at the end of this file), but this may incorrect.  Consider the  code below:

figure(1)
nu = linspace(1,2);
yy = sqrt(2*chi2inv(0.5,nu) ./ nu );
y2 = -0.1394*(nu.^2) + 0.6355*nu + 0.4612;
plot(nu,yy,'-;chisquare distribution function;', nu, y2,'-;quadratic approx;');
grid on
title('check quadratic approximation');

The two plots should match fairly closely, but as of octave 2.9.13, they are now off by about a factor of two.  I notice that they match almost perfectly if I reverse the order of the arguments to chi2inv, so perhaps this is the appropriate action for those of us using the old function.

I don't know whether the above issue is a bug or not. However,  it took me several days to track it down in my simulation work, so I thought I should report it to the list in case someone else has this problem as well.

Yours,
 diff -c ~/gaminv.m /sw/share/octave/2.9.13/m/statistics/distributions/gaminv.m
*** /Users/hodelas/gaminv.m     Wed Sep 19 09:08:20 2007
--- /sw/share/octave/2.9.13/m/statistics/distributions/gaminv.m Fri Sep  7 09:44:49 2007
***************
*** 59,67 ****
      if (!isscalar(a) || !isscalar(b))
        a = a (k);
        b = b (k);
!       y = a ./ b;
      else
!       y = a / b * ones (size (k));
      endif
      x = x (k);
      l = find (x < eps);
--- 59,67 ----
      if (!isscalar(a) || !isscalar(b))
        a = a (k);
        b = b (k);
!       y = a .* b;
      else
!       y = a * b * ones (size (k));
      endif
      x = x (k);
      l = find (x < eps);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]