Inverse Normal Program for HP 42s - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Inverse Normal Program for HP 42s (/thread-22551.html) |
Inverse Normal Program for HP 42s - cylurian - 10-23-2024 04:47 AM I'm looking for suggestions on how to create a program for the HP42S and DM42 to calculate the inverse normal. Specifically, if I have the mean, standard deviation, and a given percentile (a probability from negative infinity to a specific x value), how can I calculate that x value? I have the CDF and PDF programs for the normal distribution (see below). Would it be possible to use these programs to write a new program for the inverse normal calculation? Any advice or examples would be greatly appreciated! thx. Code:
Code: 00 { 31-Byte Prgm } RE: Inverse Normal Program for HP 42s - Thomas Klemm - 10-23-2024 07:52 AM Something like this? Code: 00 { 31-Byte Prgm } Code: 00 { 26-Byte Prgm } Code: 00 { 42-Byte Prgm } Example FIX 06 0.000001 STO "ACC" XEQ "cdf↑-1" μ?0.000000 5 R/S s?1.000000 2 R/S %ile?0.500000 0.95 R/S 8.289707 RE: Inverse Normal Program for HP 42s - cylurian - 10-23-2024 09:00 PM This is the final version of the Inverse Normal program for the DM42, which may also be compatible with the HP 42S. When you execute the program, it will prompt you to input the mean, standard deviation, and the desired percentile from negative infinity. After entering each value, press the R/S (Run/Stop) button to proceed to the next input. The accuracy is built-in (1E-12) so you don't have to worry about entering that number. You can always change that. The entire program is contained in a single sequence. Thanks Thomas for helping me put this together. Learning more as I do these. Code:
RE: Inverse Normal Program for HP 42s - Thomas Klemm - 11-20-2024 03:44 AM For percentiles close enough to 50% (say 20% - 80%) the following approximation can be used: Code: 00 { 48-Byte Prgm } This method can also be used on calculators without solve and integrate. Make sure that the calculator is in RAD mode. Example XEQ "cdf↑-1" μ?0.000000 5 R/S s?1.000000 2 R/S %ile?0.500000 0.8 R/S 6.683394 Compare this to the proper value: 6.683242 For those wondering why this works: \( \begin{align} \sin\left(\sin(x)\right) &= x - \frac{x^3}{3} + \frac{x^5}{10} - \frac{8 x^7}{315} + \frac{13 x^9}{2520} + \mathcal{O}\left(x^{11}\right) \\ \\ \int_0^x e^{-t^2} dt &= x - \frac{x^3}{3} + \frac{x^5}{10} - \frac{x^7}{42} + \frac{x^9}{216} + \mathcal{O}\left(x^{11}\right) \\ \end{align} \) They have the same degree-5 Taylor approximation. |