Post Reply 
HP 42s Program Normal Distibution
10-18-2024, 06:51 AM (This post was last modified: 10-18-2024 08:09 AM by Thomas Klemm.)
Post: #2
RE: HP 42s Program Normal Distibution
(10-17-2024 05:06 AM)cylurian Wrote:  (…) but it didn’t work on my DM42.
(…) and that didn’t work either.

That is not very specific.
Describe what you did and what the result was.

(10-17-2024 05:06 AM)cylurian Wrote:  I’m looking for a program that can calculate both a lower and upper bound simultaneously, rather than the old approach we used in the 80s where it was just left tail or right tail.

The pdf of the normal distribution is:

\(
pdf(x)=\frac{1}{\sigma\sqrt{2\pi}}e^{-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2}
\)

This is the corresponding program for the HP-42S:
Code:
00 { 34-Byte Prgm }
01▸LBL "pdf"
02 MVAR "x"
03 RCL "x"
04 RCL- "μ"
05 RCL÷ "s"
06 X↑2
07 -2
08 ÷
09 E↑X
10 RCL÷ "s"
11 2
12 PI
13 ×
14 SQRT
15 ÷
16 END

We can then use ∫f(x) to integrate it.

Initialization

Store \(\mu\) and \(\sigma\) in registers "μ" and "s".

Example

\(\mu=0\)
\(\sigma=1\)

\(\int_1^2 pdf(x) \;\mathrm{d}x\)

FIX 06

0 STO "μ"
1 STO "s"

∫f(x)

Select ∫f(x) Program
pdf

Set Vars; Select ∫var
x

LLIM=1.000000
ULIM=2.000000
ACC=0.000001

∫=0.135905



This can then be used in a program to calculate the normal distribution:
Code:
00 { 26-Byte Prgm }
01▸LBL "N"
02 STO "ULIM"
03 R↓
04 STO "LLIM"
05 PGMINT "pdf"
06 INTEG "x"
07 END

Example

1 ENTER 2
XEQ "N"

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


Messages In This Thread
RE: HP 42s Program Normal Distibution - Thomas Klemm - 10-18-2024 06:51 AM



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