Post Reply 
(35S) Statistical Distributions Functions
10-31-2015, 09:05 PM (This post was last modified: 10-31-2015 09:45 PM by Dieter.)
Post: #43
RE: HP 35s Statistical Distributions Functions
(10-29-2015 07:18 AM)Dieter Wrote:  I am not quite happy with the initial guess of the Chi² quantile. This is a very stripped down version of what's implemented in the 34s. But a more sophisticated version that usually converges within 3...5 iterations would require an estimate for the Normal quantile, which is also true for the Student inverse. So this can be done in a unified package that includes all three (or four) distributions.

Status report: I am currently working on such a package, and I think it looks not too bad. The package can evaluate the Normal, Student, Chi² and partially F distribution's PDF, CDF and their inverses (except F). The inverse usually requires just a few iterations since the initial guesses are close to the true result. Switching between CDF/PDF and inverse is done by setting Flag 1 (think of "1nverse" ;-)). There are common input routines for the degrees of freedom (with error checks), the random variable X and the probability p.

Numerically the major limits are the far Student's distribution tails, so if you need accurate CDFs below, say, 1E–10 a more sophisticated algorithm has to be used. That's why I am trying to implement the regularized Beta function. Which currently works fine with a series expansion for most practical cases of the F distribution.

Here are some results:

Code:
Normal distribution
    [XEQ] N [ENTER]     M?
Enter my
     0 [R/S]            S?
Enter sigma
     1 [R/S]            X?
Enter random variable
     1,5 [R/S]          0,129517596   PDF
                        0,933192799   CDF
Do another calculation
     [R/S]              X?
     -2 [R/S]           0,053990967   PDF
                        0,022750132   CDF
Calculate a quantile
     SF 1 [R/S]         P?
     0,95 [R/S]         1,637300567
                        1,644853622

     [R/S]              1,644853622
                        1,644853627

Student's t distribution
    [XEQ] T [ENTER]     J?
Enter degress of freedom
     10  [R/S]          P?
Determine 90% quantile
     0,9 [R/S]          1,349994793
                        1,372181030
     [R/S]
                        1,372181030
                        1,372183641
     [R/S]
                        1,372183641
                        1,372183641
Switch back to CDF mode
     CF 1
and start over
     [XEQ] T [ENTER]    J?
     [R/S]              X?
     2,5  [R/S]         0,026938728   PDF
                        0,984276578   CDF

Chi² distribution
    [XEQ] C [ENTER]     J?
Enter degrees of freedom
     5,7 [R/S]          J?
rejected, as dof must be a positive integer
     5 [R/S]            X?
Enter random variable
     9,5 [R/S]          0,033688016   PDF
                        0,909292608   CDF
Determine 90% quantile
     SF 1 [R/S]         P?
     0,9  [R/S]         9,166552063
                        9,236250476
     [R/S]
                        9,236250476
                        9,236356899
     [R/S]
                        9,236356899
                        9,236356900
Reset to CDF mode
     CF 1

Fisher's F distribution
    [XEQ] F [ENTER]     J?
nominator degrees of freedom
     20 [R/S]           K?
denominator degrees of freedom
     10 [R/S]           X?
Enter random variable
     2,8 [R/S]          0,048540378   1-CDF
                        0,951459622   CDF

(Fisher PDF and quantile are not yet implemented)

The F distribution is evaluated via an (experimental) regularized Beta function. Once this runs sufficiently fast and accurate, this can also be used for the Student case.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 35s Statistical Distributions Functions - Dieter - 10-31-2015 09:05 PM



User(s) browsing this thread: 2 Guest(s)