Showing posts with label arithmetic mean. Show all posts
Showing posts with label arithmetic mean. Show all posts

Saturday, August 5, 2023

HP 12C: Log-Normal Distribution Parameter Conversions

HP 12C:   Log-Normal Distribution Parameter Conversions


Introduction

The log-normal distribution is transformation of a standard normal variable, where for a standard normal variable t, then a random variable x follows a log-normal distribution, with the form:

x = e^(μ + t * σ)

where:

μ = mean
σ = standard deviation (sample)

The distribution takes the positive values of x.  The cumulative distributive function of the log-normal distribution (the area between 0 and x) is:

pdf = 1/2 * (1 + erf((ln x - μ) ÷ (σ * √2)) )

erf is the error function.

erf(θ) = 2 ÷ √(π) * ∫(e^(-s^2) ds, s = 0 to s = θ)


This program on today's blog focuses on the relationship between the distribution mean (μ), standard deviation (σ), the arithmetic expected value (E[x]), and the arithmetic variance (Var[x]):

E[x] =e^(μ + σ^2 ÷ 2)

Var[x] = (e^(σ^2) - 1) * e^(2 * μ + σ^2)

μ = ln( E[x]^2 ÷ √(Var[x] + E[x]^2) )

σ = √( ln (1 + Var[x] ÷ E[x]^2 ) )


HP 12C Program:  Log-Normal Distribution Parameter Conversions


Calculate E[x] and Var[x] from μ and σ

Instructions:

To find E[x] and Var[x]:
1.  Store μ in memory register 1
2.  Store σ in memory register 2
3.  Run the program.  E[x] is shown in the X stack and is stored in memory register 3.  Var[x] is shown in the Y stack in memory register 4.  

Code:
(Step:  Key Code:   Key)
(assume program starts with step 00)

01:  45, 2:   RCL  2
02:  2:    2
03:  21:  y^x
04:  44, 0:   STO 0
05:  43, 22:  e^x
06:  1:  1
07:  30:  -
08:  2:  2
09:  45, 1:  RCL 1
10:  20:  ×
11:  45, 0:  RCL 0
12:  40:  +
13:  43, 22:  e^x
14:  20:  ×
15:  44, 4:  STO 4
16:  45, 0:  RCL 0
17:  2:   2
18:  10:  ÷
19:  45, 1:  RCL 1
20:  40:   +
21:  43, 22:  e^x
22:  44, 3:  STO 3
23:  44, 33, 00:  GTO 00

Lines 01 to 03:   Store σ^2 in memory register 0


Examples  (answers are rounded to four decimal places):

Example 1
Inputs:  μ = 1, σ = 0.5
Results:  E[x] = 3.0802, Var[x] = 2.6948

Example 2
Inputs:  μ = 0, σ = 1
Results:  E[x] = 1.6487,  Var[x] = 4.6708


Calculate μ and σ from E[x] and Var[x]


Instructions

To find μ and σ:
1.  Store E[x] in memory register 3
2.  Store Var[x] in memory register 4
3.  Run the program.  μ is shown in the X stack and is stored in memory register 1.  σ is shown in the Y stack in memory register 2.  

Code:
(Step:  Key Code:   Key)
(assume program starts with step 00)

01:  45, 4:  RCL 4
02:  45, 3:  RCL 3
03:  2:   2
04:  21:  y^x
05:  44, 0:  STO 0
06:  10:  ÷
07:  1:  1
08:  40:  +
09:  43, 23:  LN
10:  43, 21:  √
11:  44, 2:  STO 2
12:  45, 0:  RCL 0
13:  45, 0:  RCL 0
14:  45, 4:  RCL 4
15:  40:  +
16:  43, 21:  √
17:  10:  ÷
18:  43, 23:  LN
19:  44, 1:  STO 1
20:  43, 33, 00:  GTO 00

Lines 01 to 03:   Store E[x]^2 in memory register 0
Lines 12 to 13:   Put two copies of memory register 0 on to the stack

Examples  (answers are rounded to four decimal places):

Example 1
Inputs:  E[x] = 1.84, Var[x] = 0.36
Results:  μ = 0.5592,  σ = 0.3180

Example 2
Inputs:  E[x] = 5.03, Var[x] = 1.72
Results:  μ = 1.5825,  σ = 0.2565

Memory Registers:
R1 = μ
R2 = σ
R3 = E[x]
R4 = Var[x]


Source

"Log-normal distribution"  Wikipedia.  Last Edited May 18, 2023 and retrieved May 24, 2023.  https://en.wikipedia.org/wiki/Log-normal_distribution

Eddie

All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 

Sunday, October 21, 2018

HP 11C (and Emulators): The Four Means

HP 11C (and Emulators):  The Four Means

Introduction

The following program uses the statistical registers to calculate four types of mean:

Arithmetic Mean:  μ = Σx / n

Harmonic Mean:  HM = n / Σ(1/x)

Geometric Mean:  GM = (Πx) ^ (1/n)

Root Mean Square:  RMS = √(Σx^2 / n)


The HP 11C uses the following registers in statistical analysis.  Be sure to clear registers by pressing [ f ] [ x<>y ] (CLEAR REG) before beginning.  Also, after clearing the registers, store 1 in register 7 (R7).  

R0 = n
R1 = Σx
R2 = Σx^2
R3 = Σy
R4 = Σy^2
R5 = Σxy

LBL A:  Enter data
LBL B:  Analysis: μ [R/S], HM [R/S], GM [R/S], RMS

HP 11C Program: The Four Means

Don't forget to store 1 in R7 prior to running the program. 

001 42, 21, 11 LBL A
002 49 Σ+
003 43, 36 LAST x
004 44, 20, 7 STO× 7
005 15 1/x
006 44, 40, 6 STO+ 6
007 43, 32 RTN

008 42, 21, 12 LBL B
009 43, 0         x-bar 
010 32 R/S
011 45, 6         RCL 6
012 15 1/x
013 45, 0 RCL 0
014 20 *
015 31 R/S
016 45, 7         RCL 7
017 45, 0         RCL 0
018 15 1/x
019 14 y^x
020 31 R/S
021 45, 2         RCL 2
022 45, 0         RCL 0
023 10 ÷
024 11 √
025 43, 32 RTN

Example:
Sample set:  4.25, 4.08, 5.63, 6.13, 4.48, 7.02 ( 6 data points )

Keystrokes:

4.25 [ f ] [ √ ] (A)
4.08 [ f ] [ √ ] (A)
5.63 [ f ] [ √ ] (A)
6.13 [ f ] [ √ ] (A)
4.48 [ f ] [ √ ] (A)
7.02 [ f ] [ √ ] (A)

[ f ] [e^x] (B)   5.2650 (arithmetic mean, μ)
[R/S] 5.0556 (harmonic mean, HM)
[R/S] 5.1575 (geometric mean, GM)
[R/S] 5.3748 (root mean square, RMS)


Eddie
All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

Casio fx-50F/Radio Shack EC-4024 Program Collection: October 2026

Casio fx-50F/Radio Shack EC-4024 Program Collection: October 2026 Notes: * The fx-50F/EC-4024 has a 29 step program space betwe...