The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

[WP34S] Chi-Square Functions Broken in 2935
Message #1 Posted by Les Wright on 2 May 2012, 8:57 p.m.

Sorry to harp on the old stats distributions again, but this is a fundamentally serious bug, not discourse on improving accuracy, etc.

In short, the CDF and PDF return zero, irrespective of the arguments entered. The inverse CDF returns a roughly close result, quickly--presumably the unrefined initial estimate.

This occurs in both the real calc and the emulator and is new. It was working fine in 2932. The regularized incomplete gamma function still works fine, FWIW, so, at least in the CDF, the problem doesn't lie there.

Thought you'd like to know ASAP about a glitch so basic and important!

Cheers--

Les

      
Re: [WP34S] Chi-Square Functions Broken in 2935
Message #2 Posted by Paul Dale on 2 May 2012, 9:51 p.m.,
in response to message #1 by Les Wright

I can see the problem here.

The cause eludes me for the moment. The chi^2 code hasn't changed between those two versions which means something more subtle is at fault.

- Pauli

            
Re: [WP34S] Chi-Square Functions Broken in 2935
Message #3 Posted by Les Wright on 2 May 2012, 10:35 p.m.,
in response to message #2 by Paul Dale

Quote:
The chi^2 code hasn't changed between those two versions which means something more subtle is at fault.

Uh oh...

                  
Re: [WP34S] Chi-Square Functions Broken in 2935
Message #4 Posted by Marcus von Cube, Germany on 3 May 2012, 3:05 a.m.,
in response to message #3 by Les Wright

I've changed some of the inner workings in the command dispatcher (there was a nasty bug lurking) and it is possible that it has broken things. I'll check.

                        
Re: [WP34S] Chi-Square Functions Broken in 2935
Message #5 Posted by Marcus von Cube, Germany on 3 May 2012, 3:30 a.m.,
in response to message #4 by Marcus von Cube, Germany

I can't see a problem with my Windows emulator here:

(Tracing is still not perfect as is the display of <= but that's not the point here.)

                              
Re: [WP34S] Chi-Square Functions Broken in 2935 - Solved
Message #6 Posted by Marcus von Cube, Germany on 3 May 2012, 3:56 a.m.,
in response to message #5 by Marcus von Cube, Germany

Put 0 in register 00 and it will work! There was a typing error in chi2.wp34s, confounding x[<=]0? with x[<=]? 00. You can see it in the trace after the BSRF 001 command (replace the space by <=).

Will be fixed in the next build.

Edited: 3 May 2012, 4:42 a.m.

                                    
Re: [WP34S] Chi-Square Functions Broken in 2935 - Solved
Message #7 Posted by Paul Dale on 3 May 2012, 6:17 a.m.,
in response to message #6 by Marcus von Cube, Germany

My error :-( Nice find too.

I was suspecting something uninitialised being the root cause here. At home I wasn't reproducing the problem....

- Pauli

                                    
Re: [WP34S] Chi-Square Functions Broken in 2935 - Solved
Message #8 Posted by Les Wright on 3 May 2012, 11:10 a.m.,
in response to message #6 by Marcus von Cube, Germany

Man that is subtle!

Sure enough, Reg 00 in both my calcs AND the emulator were nonzero due to some detritus left by user programs of my own I was running.

I verily thought I was losing my mind. Glad the fix was so easy, if tough to find.

Les

P.S. I am delighted to see work on the upper-tail distributions in progress. When computing inverses for cumulative probabilities close to 1, it will be much more accurate to work with an upper tail probability close to 0. One can already do this for the normal, t, and F. The first two are symmetrical and it boils down to working with the a probability less than .5 and flipping the sign later if necessary. The F distributions tails are related by swapping the numerator and denominator dfs and taking the reciprocal of the quantile. The challenging one with the existing calculator configuration is chi-squared, but this is simply a special case of the right-sided incomplete regularized gamma, which in the upper tail is very rapidly and accurately computed by its continued fraction. Indeed, I vote that the calculator offer the right-sided incomplete gamma explicitly so that it can be calculated accurately deep into the upper-tail if desired. I have no expertise with the other less common distributions so can't comment. My 2 euros.

Edited: 3 May 2012, 1:22 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall