Post Reply 
(35S) Statistical Distributions Functions
10-28-2015, 12:24 AM
Post: #21
RE: HP 35s Statistical Distributions Functions
(10-27-2015 10:25 PM)Dieter Wrote:  
(10-27-2015 07:32 PM)Dieter Wrote:  BTW, at the moment I am looking at an 35s implementation of the HP67 routines.

OK, here is a first experimental version of the Chi² algorithm used in the HP67 Stat Pac. PDF and CDF are calculated simultaneously, and both are returned in Y and X. Here is the code:

Code:
C001  LBL C
C002  INPUT J
C003  e
C004  IP
C005  STO T
C006  ÷
C007  !
C008  STO G
C009  INPUT X
C010  XEQ C013
C011  STOP
C012  GTO C009
C013  RCL X
C014  RCL÷ T
C015  +/-
C016  e^x
C017  LASTx
C018  +/-
C019  RCL J
C020  RCL÷ T
C021  y^x
C022  x
C023  RCL÷ G
C024  STO A
C025  RCL J
C026  STO B
C027  SGN
C028  ENTER
C029  -
C030  ENTER
C031  ENTER
C032  LASTx
C033  RCLx X
C034  RCL B
C035  RCL+ T
C036  STO B
C037  ÷
C038  +
C039  x≠y?
C040  GTO C030
C041  RCL A
C042  RCL X
C043  x=0?
C044  e^x
C045  ÷
C046  RCLx J
C047  RCL÷ T
C048  x<>y
C049  RCLx A
C050  RCL+ A
C051  RTN

Usage (results as shown in FIX 9 mode):

Code:
[XEQ] C [ENTER]             J=?

Enter degrees of freedom
    10  [R/S]               X=?

Enter random variable X
    6,3 [R/S]               0,087896860   // =PDF(6,3|10)
                            0,210539719   // =CDF(6,3|10)
Do another calculation
        [R/S]               X=?
    20  [R/S]               0,009458319   // =PDF(20|10)
                            0,970747312   // =CDF(20|10)

As usual, comments, suggestions and error reports are welcome. ;-)

Since the main computation routine (C013 ff.) returns both the PDF and the CDF, adding a function that determines the inverse (quantile) is rather simple. I tried an approach using a second-order (Halley) method and it worked well for me. This required about 30 additional lines of code.

Dieter

Dieter, the program works perfect!. Please include the function for the inverse, no mather how long it takes
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 35s Statistical Distributions Functions - PedroLeiva - 10-28-2015 12:24 AM



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