HP Forums

Full Version: Geometric mean and HP calculators
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Can any HP calculators crunch a geometric mean for an easily editable list of numbers without requiring the entry of a separate program?

I doubt that any HPs have a convenient "Geometric Mean" function. But you can get the desired result on the HP-48, and presumably on the more recent HP-49 and HP-50, through a series of steps:

1. Enter your raw data as a "list". Store the list for future editing if desired.

2. Hit LOG or LN to transform all of the values in the list. Now you have a second, log-transformed list.

3. Disassemble the log-transformed "list" and reassemble it as an "array". Save the array as "SigmaDAT", which is the reserved name for statistics data.

4. Hit MEAN to calculate the mean of the log-transformed data in the "SigmaDAT" array.

5. Hit the appropriate antilog (10^X or e^X) for the geometric mean.

Probably you could write simple programs to automate this process. There may be other ways to do it.

Edited: 30 Nov 2006, 2:12 p.m. after one or more responses were posted

The following HP48 program seems to work for me:












Enter and save your list of raw data (Step 1). Then put it on the stack, and run the program. It quickly executes Steps 2 to 5, and the result is the geometric mean. The only tricky part is converting the list to an array (Step 3).

Edited: 30 Nov 2006, 1:57 p.m.

Once you have the list of numbers, apply the pList function against the list and then get the n root to the function result.

pList function - p is the greek pi character (alpha right shift P)

1. Put number in a list such as {13 22 17 19}

2. Apply pList function to your list. This will give you a multiplied sum - 92378

3. Get the root of the pList sum where the root value is the number of elements in the list - that is the 4th root of 92378 giving 17.43 as the geometric mean (put 4 on stack and use keys alpha right shift R)

You can compare your calculator results here

Edited: 1 Dec 2006, 7:47 a.m.

That's more elegant than my approach. A few comments:

- For Step 3, you could use the SIZE function to determine the number of elements in the list.

- You are apparently not using an HP-48, because I have different keys for the "Pi" in the Pi-LIST command and for the XROOT function.

- The product generated by Pi-LIST could conceivably generate an overflow error if the list was very large, and/or contained very large values

Edited: 1 Dec 2006, 1:01 p.m.

How about using the statistics lists in the 27S/17B/17BII/17BII+/ etc. along with a small solver equation. This is a very easy list editor to use and the equation is fairly simple. Assuming the list is called GMEAN the equation would be something like:


To use this, just create a list in SUM and name it GMEAN. Edit it as needed and when you want to compute the geometric mean go into SOLVE, pick the 'GMEAN' equation and hit the GMEAN key.

You could also use the cash flow lists and then you'd be able to use the number of occurrences as well with only a slightly more complicated solver equation.


I'm using the 50g. Geometric mean is described in the 50g reference manual pg 8-15 but the result they show for the example is wrong (one of many errors in that book).

The answer is 1.9307... not 1.0032..... Example reversed the root (took 720th root of 10 insteead of 10th root of 720).



"That's more elegant than my approach."

Not really. The approach which uses logarithms delays the onset of the overflow problems which are inherent in this kind of calculation.

While using logs gives you much smaller numbers, getting an overflow with Pi-List is unlikely since overflow >= 10^500.

Here's the program, assuming the list is on stack 1

<< -> list
<< list Pi-LIST list SIZE XROOT

where 'Pi-' is the mathematical pi character.

Edited: 2 Dec 2006, 11:23 a.m.