Post Reply 
Accurate Bernoulli numbers on the 41C, or "how close can you get"?
03-19-2014, 06:47 AM (This post was last modified: 03-19-2014 06:52 AM by Ángel Martin.)
Post: #17
RE: Accurate Bernoulli numbers on the 41C, or "how close can you get"?
Hi Dieter, glad to see you find the SandMath worth looking at. Which revision are you using? Are there two appendices 9a and 9b, or only one appendix 9?

http://hp41.claughan.com/file/SANDMATH_4...Manual.pdf

I say this because in the latest versions (Revision "M", see above link) there are a couple of functions directly related to the quantile, one (ICPF) using the inverse error function on a general Normal distribution (s,m), and another (QNTL) using Halley's iterative method on a standard Normal (0,1). The functions are a bit buried in the -FACTORIAL group, in the sub-functions FAT

The manual has room for improvement, but isn't the quantile function QNTL what you're asking about? It is briefly (and poorly) documented in page 48. Below you can see the FOCAL code for this function, which uses Halley's method to solve for a CPF (Cumulative Probability Function) equation equal to the quantile's value. The convergence criteria is a poor E-7, probably not what you're looking for I'm afraid.

Code:

01    LBL "QNTL"
02    STO 03
03    CLX
04    STO 04
05    LBL 01
06    0
07    ENTER^
08    1
09    RCL 04
10    CPF
11    RCL 03
12    -
13    STO 05
14    0
15    ENTER^
16    1
17    RCL 04
18    PDF
19    RCL 05
20    X<>Y
21    ST* Y
22    X^2
23    LASTX
24    RCL 04
25    *
26    RCL 05
27    *
28    2
29     /
30    +
31     /
32    ST- 04
33    ABS
34    E-7
35    X<Y?
36    GTO 01
37    END

As per ICPF, it's a much simpler code since IERF does all the work in there:

Code:

01    LBL "ICPF" 
02    ST+ X
03    E
04    -
05    IERF
06    2
07    SQRT
08    *
09    *
10    +
11    END

I use the CUDA library algorithms to calculate the inverse error function - it's a very fast implementation (yes, even on a normal HP-41) that takes a huge MCODE listing code.

I may be confusing subjects, statistics is not my forte (I'm really a jack of all trades and master of none, as I'm sure you have noticed ;-) I think this function is equivalent to the 38E's, but haven't looked at the 34S at all (don't have one myself).

l hope this clarifies, but let me know if you see any issues or would like additions/changes made.

Best,
'AM
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Accurate Bernoulli numbers on the 41C, or "how close can you get"? - Ángel Martin - 03-19-2014 06:47 AM



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