Post Reply 
(50g) Normal Distribution
12-03-2018, 07:05 PM
Post: #2
RE: (50g) Normal Distribution
(12-03-2018 04:20 PM)John Keith Wrote:  Either function can be obtained from the other by subtracting the value from 1 as detailed in the above linked threads. For example, the lower-tail normal CDF would simply be
Code:
\<< UTPN 1. SWAP - \>>

Yes, that's simple, but not a good idea. Try this for x=–10 to see why. ;-)

A better method that returns accurate results is this one (in pseudocode – you will know how to do this on the 50g):

Code:
p = UPTN(abs(x))
if x>0 then p = 1-p
return p

By the way, another useful function is the two-sided symmetric CDF A(x), i.e. the integral from –x to +x. Here similar considerations apply to get an accurate result for any x. If A(x) is calculated the tricky part is maintaining a decent accuracy for x close to 0, while for 1–A(x) the less trivial cases are those with large x. But this requires more than just a function for the upper or lower tail integral. What we need is an accurate value for the integral from 0 to x. Otherwise the trivial way of calculating A(x) = 1–2·UPTN(abs(x)) will suffer from digit cancellation for x<0,12566... As a rule of thumb, at x=10–n the last n digits are lost. But in praxi this admittedly is not much of a problem. And for x<10–6 you can simply set A(x) = x·√(2/pi). ;–)

(12-03-2018 04:20 PM)John Keith Wrote:  The normal PDF Z(x), which is implemented on the Prime as NORMALD, is not built in to the HP 50. It can be easily calculated with the following program:
Code:
\<< UNROT 2. * UNROT - SQ OVER / NEG EXP SWAP 3.14159265359 * \v/ /
\>>

3,14159265359? Does the 50g not have a constant for pi ?-)
Instead of 3,14159265359 you could directly code √(2pi) = 2,50662827463.

But, more important, this direct method is not exact for large x. The reason for the problem is explained more detailled in the HP67/97 program thread you have linked to. If you take a look at the program you will see a more elaborate method for calculating Z(x) which provides better accuracy.

(12-03-2018 04:20 PM)John Keith Wrote:  Next, a program to generate normally distributed random numbers.

Does the 50g also offer the inverse Normal CDF, i.e. the quantile function? Then you can also use this function to generate normally distributed random numbers.

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


Messages In This Thread
(50g) Normal Distribution - John Keith - 12-03-2018, 04:20 PM
RE: (50g) Normal Distribution - Dieter - 12-03-2018 07:05 PM
RE: (50g) Normal Distribution - John Keith - 12-03-2018, 08:45 PM
RE: (50g) Normal Distribution - Dieter - 12-03-2018, 10:18 PM
RE: (50g) Normal Distribution - John Keith - 12-03-2018, 10:59 PM
RE: (50g) Normal Distribution - John Keith - 12-04-2018, 08:54 PM
RE: (50g) Normal Distribution - Dieter - 12-04-2018, 09:48 PM
RE: (50g) Normal Distribution - Dieter - 12-05-2018, 08:49 PM
RE: (50g) Normal Distribution - John Keith - 12-06-2018, 02:58 PM
RE: (50g) Normal Distribution - Dieter - 12-06-2018, 11:08 PM
RE: (50g) Normal Distribution - John Keith - 12-07-2018, 11:21 PM
RE: (50g) Normal Distribution - Dieter - 12-06-2018, 10:54 PM
RE: (50g) Normal Distribution - John Keith - 12-08-2018, 07:13 PM
RE: (50g) Normal Distribution - Dieter - 12-08-2018, 09:18 PM
RE: (50g) Normal Distribution - John Keith - 12-08-2018, 09:28 PM
RE: (50g) Normal Distribution - John Keith - 01-26-2019, 10:01 PM
RE: (50g) Normal Distribution - pier4r - 01-26-2019, 10:12 PM



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