(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 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)) 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: 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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)