Post Reply 
(35S) Statistical Distributions Functions
10-28-2015, 07:54 PM (This post was last modified: 10-28-2015 08:00 PM by Dieter.)
Post: #29
RE: HP 35s Statistical Distributions Functions
(10-28-2015 06:21 PM)PedroLeiva Wrote:  I think we have tight-fitting Student t-distribution. I attached the pdf with the program that Thomas wrote, five calculation examples (test cases), an outline of the distribición and an instruction table for input and output of data.

For the record, here is a version without using the Integrate function. It is based on algorithm AS 3, published as a Fortran program in Applied Statistics (1968). This version includes an improved input routine for the degrees of freedom in that it checks whether the input is a positive integer. Again, both the PDF and CDF are returned on the stack (in Y and X). Code for the inverse is not yet included.

Code:
T001  LBL T
T002  ALL
T003  INPUT J
T004  ENTER
T005  ABS
T006  IP
T007  x=y?
T008  x=0?
T009  GTO T001
T010  e
T011  IP
T012  STO T
T013  SGN
T014  -
T015  RCL÷ T
T016  !
T017  LASTx
T018  RCL T
T019  1/x
T020  -
T021  !
T022  ÷
T023  Pi
T024  RCLx J
T025  √x
T026  ÷
T027  STO G
T028  FIX 9
T029  INPUT X
T030  RCL J
T031  √x
T032  ÷
T033  STO A
T034  RCL J
T035  RCL X
T036  x²
T037  RCL+ J
T038  ÷
T039  STO B
T040  RCL J
T041  RCL T
T042  RMDR
T043  RCL+ T
T044  STO K
T045  SGN
T046  STO C
T047  ENTER
T048  ENTER
T049  RCL K
T050  RCL- J
T051  x≥0?
T052  GTO T066
T053  SGN
T054  RCL+ K
T055  RCLx B
T056  RCL÷ K
T057  RCLx C
T058  STO C
T059  +
T060  x=y?
T061  GTO T066
T062  RCL T
T063  STO+ K
T064  R↓
T065  GTO T047
T066  R↓
T067  STO C
T068  RCL J
T069  RCL T
T070  RMDR
T071  x=0?
T072  GTO T090
T073  RCL- J
T074  x=0?
T075  STO C
T076  RCL A
T077  RCLx B
T078  RCLx C
T079  Pi
T080  ÷
T081  RCL A
T082  ATAN
T083  RCL T
T084  +/-
T085  SGN
T086  ACOS
T087  ÷
T088  +
T089  GTO T095
T090  RCL B
T091  √x
T092  RCLx A
T093  RCLx C
T094  RCL÷ T
T095  RCL T
T096  1/x
T097  +
T098  RCL X
T099  x²
T100  RCL÷ J
T101  RCL T
T102  SGN
T103  +
T104  LASTx
T105  RCL+ J
T106  RCL÷ T
T107  +/-
T108  y^x
T109  RCLx G
T110  x<>y
T111  STOP
T112  GTO T028

Here is Thomas' sample case:

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

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

Enter random variable X
    1,5 [R/S]               0,126263061   // =PDF(1,5|7)
                            0,911350757   // =CDF(1,5|7)
Do another calculation
        [R/S]               X=?
    -2  [R/S]               0,063135337   // =PDF(-2|7)
                            0,042809664   // =CDF(-2|7)

Final remark: like the other programs discussed in this thread, this is a rather simple and straightforward implementation that works fine for most practical cases. However, far out in the distribution tails the results may lose accuracy due to rounding, and eventually values may round to 0 or 1. For instance, for 7 d.o.f. and x=–100 you will get a CDF of 2,000...E–12 while the exact result is 1,318 E–12, and for x=0 the returned result is zero while it actually is 1,69 E–17. If you want more or less exact values even for such extreme arguments, a different approach is required.

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-28-2015 07:54 PM



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