HP Forums
HP 50g normal distribution - 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: HP 50g normal distribution (/thread-15094.html)



HP 50g normal distribution - Cristi Neagu - 05-30-2020 03:32 PM

Hello,

I'm trying to plot a normal distribution on the 50g. I know the function NDIST gives the value of the curve at a given value of x, based on a mean and standard deviation. Problem is i can't figure out how to use it in a program or equation that i can then use in the plotting function.
I know that NDIST takes 3 parameters on the stack, but i can't figure out how to use it. I tried this:
Code:
<< X -> << 100 10 X NDIST >> >>
Which works as expected if i have a number on the stack, but when i go in the Y= window, i can't choose it if it's saved as a program. So i figure that the program i made must be formatted wrong, so it's not recognized as something that can be plotted. So i wrote a random equation in the Y= editor, and this is how it saved it:
Code:
<< X -> 'X+1' >>
So i tried using NDIST in that format, but i keep getting syntax errors.

So... how can i plot a normal distribution? Is using NDIST the right approach? Is there a better way?

Thank you.


RE: HP 50g normal distribution - peacecalc - 05-30-2020 09:33 PM

Hello Christi Neagu,

If you can't get what you want, code it by yourself, this works:
Key in this:

'NP(x) = 1/SQRT(2*pi)*EXP(-(X-5)^2/2)'
Use the function DEF for getting a function out of the equation above. For example this function is defined for a mean = 5 and a variance = 1 and X for the function variable. The function NP(X) can be plottet with Y1(X) = NP(X).

Try it andf enjoy!

Sincerely peacecalc


RE: HP 50g normal distribution - Cristi Neagu - 05-30-2020 10:19 PM

Hello,

Thank you for the reply. Yes, that does work. Still, is there any way NDIST can be used? Now i'm asking just to understand User RPL a bit better.


RE: HP 50g normal distribution - peacecalc - 05-30-2020 11:17 PM

Hello Christi Neagu,

I used your program << X -> << 100 10 X NDIST >> >> stored it in 'NP' und used Y1(x)=NP(X) and plotting worked fine! But of course you have to change xmin and xmax to let's say 95 and 105 because you programmed the mean = 100. The maximal value of NP ist something about 0,13 at X = 100 you also have to change ymin and ymax let's say to -0,05 an 0,15 and you see a wonderful bell.


RE: HP 50g normal distribution - Cristi Neagu - 05-30-2020 11:21 PM

(05-30-2020 11:17 PM)peacecalc Wrote:  Hello Christi Neagu,

I used your program << X -> << 100 10 X NDIST >> >> stored it in 'NP' und used Y1(x)=NP(X) and plotting worked fine! But of course you have to change xmin and xmax to let's say 95 and 105 because you programmed the mean = 100. The maximal value of NP ist something about 0,13 at X = 100 you also have to change ymin and ymax let's say to -0,05 an 0,15 and you see a wonderful bell.

Ah ok. That was my mistake i guess. I didn't think about calling it the way you did. I only tried the "choose" option from the Y= screen. Thanks for pointing that out!


RE: HP 50g normal distribution - peacecalc - 05-31-2020 05:03 PM

Hello Christi Neagu,

in my humble opinion it is not a specific RPL feature, it is the way the function NDIST is programmed: it only works fine with reals or integers, but not with symbolic variables. 'X' seems to be one, but it is a concrete number. And you can't use it as 'NDIST(100, 10, X)' in an algebraic expression. The probalistic integral functions UTPX have the similar problem, you can use them in RPL programming but not as an algebraic function.

And of course the "Y=" interface has its own rules, which have to be respected (like every solution for a certain input).

Sincerely peacecalc


RE: HP 50g normal distribution - Csaba Tizedes - 06-03-2020 10:39 PM

(05-30-2020 03:32 PM)Cristi Neagu Wrote:  
Code:
<< X -> << 100 10 X NDIST >> >>
works as expected if i have a number on the stack
Code:
<< X -> 'X+1' >>
syntax errors

I guess this is only a typo by your side, but the local variable structure is << -> var <<prg>> >> or << -> var 'algebraic' >>

Csaba


RE: HP 50g normal distribution - Cristi Neagu - 06-03-2020 11:07 PM

(06-03-2020 10:39 PM)Csaba Tizedes Wrote:  I guess this is only a typo by your side, but the local variable structure is << -> var <<prg>> >> or << -> var 'algebraic' >>

Csaba

Hello,

Yes, you're right. It was a typo.