HP Forums
(12C) Geometric Mean with Percentage - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (12C) Geometric Mean with Percentage (/thread-22027.html)



(12C) Geometric Mean with Percentage - Gamo - 07-13-2024 05:26 AM

To calculate the overall geometric mean percentage increase,
you can use the following formula:

GM% = [ n√(1+r1)(1+r2)(1+r3)...... ] - 1

--------------------------------------------------------------------

Procedure:

Initialize by [f] REG to clear all Store Register

Input Percent Data then [R/S] display show Data Count 1, 2 .... n

When done press 0 [R/S] display answer GM%

---------------------------------------------------------------------

Example: FIX 2

An investor has annual return of 5%, 10%, 20%, -50%, and 20%.

[f] REG

5 [R/S] display 1
10 [R/S] display 2
20 [R/S] display 3
-50 [R/S] display 4
20 [R/S] display 5

0 [R/S] display answer -3.62

This results in a -3.62% annual return.

--------------------------------------------------------------------------
Program:
Quote:01 ENTER
02 1
03 %
04 LSTx
05 +
06 STO 0
07 1
08 STO 1
09 R/S
10 X=0
11 GTO 21
12 1
13 %
14 LSTx
15 +
16 STOx0
17 1
18 STO+1
19 RCL 1
20 GTO 09
21 RCL 0
22 RCL 1
23 1/x
24 Y^X
25 1
26 -
27 EEX
28 2
29 x
30 GTO 00

Gamo 7/2024


RE: (12C) Geometric Mean with Percentage - Thomas Klemm - 07-13-2024 07:08 PM

You could just add 100 to the percentages, calculate the geometric mean and subtract 100 from the result.

Also the logarithm could be used to translate the geometric to the arithmetic mean:

\(
\log(\sqrt{x \cdot y}) = \frac{\log{x} + \log{y}}{2}
\)

This program enters the data:
Code:
01-       26 : EEX
02-        2 : 2
03-       40 : +
04-    43 23 : g LN
05-       49 : Σ+

To calculate the geometric mean use:
Code:
01-    43  0 : g x̄
02-    43 22 : g eˣ
03-       26 : EEX
04-        2 : 2
05-       30 : -



RE: (12C) Geometric Mean with Percentage - Albert Chan - 07-13-2024 08:30 PM

(07-13-2024 07:08 PM)Thomas Klemm Wrote:  You could just add 100 to the percentages, calculate the geometric mean and subtract 100 from the result.

Or, subtract 100% from each calculation: (1+r1) * (1+r2) - 1 = r1*(1+r2) + r2

Code:
%
LstX
+
+

5 Enter
10 R/S      → 15.5
20 R/S      → 38.6
-50 R/S     → -30.70
20 R/S      → -16.84

Investment return, "average" = -16.84 / 5 = -3.37%
APY = ((1 + -16.84/100)^(1/5)-1) * 100% ≈ -3.62%

Note: Arithmetic mean of returns = (5+10+20-50+20)% / 5 = 1%, yet ROI is negative!


RE: (12C) Geometric Mean with Percentage - Gamo - 07-14-2024 11:45 AM

Program update with added feature to include the arithmetic mean.

---------------------------------------------------------------------------

Procedure:

For a new computation, clear statistic registers by pressing [f] ∑

Enter a percentage and press [R/S]

Data Count is temporary displayed and then displaying geometric mean of percentage.
Press [X<>Y] for Arithmetic Mean

Repeat percentage entry using the [R/S] key for each elements of the list.

-----------------------------------------------------------------------------
This example is from HP-12C User's Handbook on Page 30

With this example I will calculate the Percent of Total with each answer
of that Percentage of Total this program also calculate the Geometric Mean with percentage.

Last month, your company posted sales of$3.92 million in the U.S., $2.36 million in Europe, and
$1.67 million in the rest of the world. What percentage of the total sales of all three region and
What is the Geometric Mean of that percentage?

[f] Σ

3.92 [ENTER]
2.36 [+] display 6.28
1.67 [+] display total 7.95 [STO] 0 // Store Total Amount for later use to find %T

While 7.95 on display
3.92 [%T] display answer 49.31 [R/S] display 1 pause and display 49.31

[RCL] 0 2.36 [%T] display answer 29.69 [R/S] display 2 pause and display 39.15
[RCL] 0 1.67 [%T] display answer 21.01 [R/S] display 3 pause and display 32.82

Data, %T, GM%
3.92, 49.31%, 49.31%
2.36, 29.69%, 39.15%
1.67, 21.01%, 32.82% // Final Answer for the GM% is 32.82%

----------------------------------------------------------------
Program:
Quote:00-
01- ENTER
02- 1
03- %
04- LSTx
05- +
06- LN
07- Σ+
08- PSE
09- x bar
10- e^x
11- 1
12- -
13- EEX
14- 2
15- ×
16- GTO 00

Thanks C.Ret for this update edition

Gamo


RE: (12C) Geometric Mean with Percentage - Thomas Klemm - 07-14-2024 12:20 PM

Or then you combine my two code snippets with the PSE command:
Code:
01-       26 : EEX
02-        2 : 2
03-       40 : +
04-    43 23 : g LN
05-       49 : Σ+
06-    43 31 : PSE
07-    43  0 : g x̄
08-    43 22 : g eˣ
09-       26 : EEX
10-        2 : 2
11-       30 : -



RE: (12C) Geometric Mean with Percentage - Gamo - 07-22-2024 09:53 AM

Geometric Mean with Percentage using TVM

Each new data set clear all Statistic, Financial and Store Registers

To Clear: [f] Σ [f] FIN [f] REG

Example: FIX 2

An investor has annual return of 5%, 10%, 20%, -50%, and 20%.

Entering the data above:

5 [ENTER] 1 [%] [LSTx] [+] display 1.05 [R/S] display 1

10 [ENTER] 1 [%] [LSTx] [+] display 1.10 [R/S] display 2

Do the rest the same way and the final data count should be 5

If you can do percent and add 1 in your head just enter the amount
and press [R/S]

When done press 0 [R/S] display answer -3.62%

Program:
Quote:01 STO 0
02 Σ+
03 R/S
04 X=0
05 GTO 09
06 STOx0
07 Σ+
08 GTO 03
09 RCL 1
10 [n]
11 1
12 CHS
13 [PV]
14 RCL 0
15 [FV]
16 [ i ]

Remark:
If you remember all the steps needed no need to use as a program demonstrated here.

Gamo 7/2024


RE: (12C) Geometric Mean with Percentage - Thomas Klemm - 07-22-2024 11:20 AM

(07-22-2024 09:53 AM)Gamo Wrote:  If you can do percent and add 1 in your head just enter the amount
(…)
If you remember all the steps needed no need to use as a program demonstrated here.

Example

105 ENTER
110 ×
120 ×
50 ×
120 ×
5 1/x
yx
100 -

-3.62