--
--Matt Bryant
"If at first you don't succeed, try, try again. Then quit. No use being
a damn fool about it."
- W.C. Fields (1880 - 1946)
"Never try to teach a pig to sing. It wastes your time and annoys the pig."
- Proverb
TW
>Is there a way to enter a set of data (ex: 6, 7, 9, 9, 9, 10) and have the
>calculator find the mean, median, and mode for that set of data? Thanks in
>advance.
~The enemy's gate is down.
If you want to know "The mean"
put on the stack the data
[[x1]
[x2]
...
[xn]]
'SIGMADAT' (SIGMA is Sumatorium symbol)
STO
MEAN .
The others stat functions i think you'll have to make your programs or
go to www.hpcalc.org.
I hope this helps you , anyway if you want me to help you to make
them, just e-mail me or post another message.
Greetings
Bernardo Aguilera
TW
> Is there a way to enter a set of data (ex: 6, 7, 9, 9, 9, 10)
> and have the calculator find the mean, median, and mode?
%%HP: T(3)F(.); @ Header for Kermit transfer
@ Mean of a list of reals
\<< DUP 0. + \GSLIST SWAP SIZE / \>> 'MEANL' STO
@ Mean of every column of a real matrix:
\<< TRN AXL 1. 'MEANL' DOLIST AXL \>> 'MEANM' STO
@ Median of a list of reals:
\<< SORT DUP SIZE 1. + 2. / DUP2 FLOOR GET
UNROT CEIL GET OVER - 2. / + \>> 'MEDNL' STO
@ Median of every column of a real matrix:
\<< TRN AXL 1. 'MEDNL' DOLIST AXL \>> 'MEDNM' STO
@ End of Downloadable file
[r->] [OFF]
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
> @ Median of a list of reals:
> \<< SORT DUP SIZE 1. + 2. / DUP2 FLOOR GET
> UNROT CEIL GET OVER - 2. / + \>> 'MEDNL' STO
@ I use the slightly shorter program
\<< SORT DUP SIZE 1. + 2. / DUP2 FLOOR GET
UNROT CEIL GET + 2. / \>> 'MEDLST' STO
> where do I put the numbers to use those tools!?
The programs which I just posted
each operate on one object on the stack (level 1):
Mean of a list of reals: { list } ==> mean
Median of a list of reals: { list } ==> median
Mean of every column of a real matrix: [[matrix]] ==> [means]
Median of every column of a real matrix: [[matrix]] ==> [medians]
I deliberately avoided reference to the reserved-name
statistics matrix '\GSDAT', so that you needn't go through
the extra steps to first store data there, but you can recall
that matrix to the stack if you want to submit it to those programs.
A special command RCL\GS recalls '\GSDAT' and errors if there is no
\GSDAT in the *current* directory (i.e. ignores parent directories).
| \<< SORT DUP SIZE 1. + 2. / DUP2 FLOOR GET
| UNROT CEIL GET + 2. / \>> 'MEDLST' STO
Let's apply both programs to the list { 6.66666666667 }
The "long" program's median is: 6.66666666667
The "short" program's median is: 6.66666666665
"And that's the long and short of it" ;)
Although we saw that a very simple bit of care in calculating
a median easily avoids some inaccuracy, especially since
only two (possibly equal) values are being averaged,
the exact same thing can happen when calculating means, e.g.
{ 6.66666666667 6.66666666667 } \GSLIST 2. / ==> 6.66666666665
If we had created a SigmaSTAT matrix, however,
containing those values in a column,
then the built-in MEAN command, using extended precision,
would calculate a precisely correct mean.
There is a more accurate method of computation, however,
even in userRPL, as explained by Bob Wheeler:
http://groups.google.com/groups?selm=328D1B...@echip.com
As used in WEIGHT3 for weighted means and standard deviations:
http://groups.google.com/groups?selm=5hipnp%24oq0%241%40news.iastate.edu
So, for a possibly more accurate mean of a list of reals
(most obviously in the above case),
use this considerably less obvious program:
\<< 0. SWAP 1. \<< OVER - NSUB / + \>> DOSUBS \>> 'MEANL' STO
-------------------- (taken from the link) --------------------
Let X(i) be an array of i=1...N interval midpoints, and W(i) a
corresponding
array of weights (frequencies). Use arrays SW(i), SX(i), and M(i)
to hold the calculations. Set SW(0)=SX(0)=M(0)=0, and then repeat
SW(i+1)=SW(i)+W(i)
d=[X(i+1)-M(i)]W(i) <<<<<<<<<<<<<<<<
M(i+1)=M(i)+d/SW(i+1)
SX(i+1)=SX(i)+d[X(i+1)-M(i+1)]
SX(N) will contain N times the variance (SD squared),
and M(N) the mean. You don't actually have to use arrays for
SW,SX, and M: scalars will do if you update them.
-------------------- (end) --------------------
d uses X(i+1), and this implies i = 0...N-1, but this conflicts with d using
W(i), since W(0) is out of range.
a basic loop-formula is (same starting values, same vars)
i = 1...N
SW += W(i) // obvious
d = W(i)*X(i)
SX += d*X(i)
M += d
at any stage, mean = M/SW, variance = (SX/SW - (M/SW)^2 ), where variance is
(how do you call that in English?) "uncorrected" (?), that is divided by N
and not by N-1
(this allows to get 0 when N=1)
--
The set of solutions is never empty.
Two solutions together form a new problem.
-- Mycroft Holmes
> There's something strange about those formulas you quoted
They worked in the WEIGHT3 program;
perhaps the reference supplied earlier by Bob Wheeler
(who supplied these formulas)
might contain a better explanation.
>> SW(i+1)=SW(i)+W(i)
> d uses X(i+1), and this implies i = 0...N-1, but this conflicts
> with d using W(i), since W(0) is out of range.
Bob said: "Set SW(0)=SX(0)=M(0)=0" so assume W(0)=0 also.
> at any stage, mean = M/SW, variance = (SX/SW - (M/SW)^2 ),
> where variance is (how do you call that in English?)
> "uncorrected" (?), that is divided by N and not by N-1
> (this allows to get 0 when N=1)
HP seems to use the terminology "population" (of all the observations)
variance, which goes to zero, and "sample" (predicted from
observations) variance, which goes to infinity at N=1.
To make a confusing comedy routine out of this, we might say that
the "population" variance means "of the sample," while the "sample"
variance means "of the entire population" -- that's why I only
choose by which is larger and which is smaller,
and don't try to remember what it's called :)
But Mycroft is a very precise mathematician,
and won't settle for just getting the right answers,
the way engineers do ;)
-[]-
uhm... talking about conflicts: they remark so much the difference between
dividing by N-1 and by N, when they also recommend to use a very large N,
otherwise the stats are meaningless...
> But Mycroft is a very precise mathematician,
> and won't settle for just getting the right answers,
> the way engineers do ;)
>
You got me ;)
However Bob's formulas should be slightly slower than the ones I had, since
they use 1 division per iteration, while I use 2 divisions at the end (but
don't ask me about numerical precision): and if N is greater than 2... ;)
I noticed StatPro49 uses some special (full screen) choose... well not a
box any more. How can I use that in my own program? Is there a
(stable/supported) flashpointer? Or did Scott Guth write it himself?
Thomas
--
Thomas Rast
t.r...@iname.com
ICQ# 103670088
It's the 48 style choose. It's there in the 49 really it's the one more
documented the new one it's only documented a bit by Carsten I think.
There is a document GXBrowser or something like this on hpcalc explaining
it.
It's the same than the 48 boxed one. It's only different
configuration/programing.
Luis.
--
---------------------------------------
Luis Morales Boisset
email: lboisset at arrakis.es
http://www.arrakis.es/~lboisset
"Thomas Rast" <t.r...@iname.com> escribió en el mensaje
news:3B94F745...@iname.com...