Post Reply 
(21S) Gompertz Curve
02-09-2023, 05:11 AM
Post: #1
(21S) Gompertz Curve
HP 21S: Gompertz Curve


Introduction

This program fits sequential data to the Gompertz Curve:

y = c * a ^ (b ^ x)

where:

b = ( (S3 - S1) / (S2 - S1) ) ^ 1/m
a = e^( (S2 - S1) / b * (b - 1) / (b^m - 1)^2 )
c = e^( 1 / m * (S1 * S3 - S2^2) / (S1 + S3 - 2 * S2) )

where:

m = number of data points / 3
S1 = Σ ln x_i of the first tier
S2 = Σ ln x_i of the second tier
S3 = Σ ln x_i of the third tier


HP 21S Program Code: Gompertz Curve

Labels:

A: initialize the program
B: enter data
C: calculate b, a, c

Registers:

R1 = natural log of the sum of the first-third of data points
R2 = natural log of the sum of the second-third of data points
R3 = natural log of the sum of the third-third of data points
R4 = n = number of data points ÷ 3
R5 = a
R6 = b
R7 = c

Program Code:

step #: key code; key

Code:
01:  61, 41, A;  LBL A
02:  51, 75; CLRG
03:  61, 26;  RTN

04:  61, 41, b; LBL B
05:  13;  LN
06:  21, 75, 1; STO+ 1
07:  26;  R/S
08:  13;  LN
09:  21, 75, 2; STO+ 2
10:  26; R/S
11:  13; LN
12:  21, 75, 3; STO+ 3
13:  1;  1
14:  21, 75, 4; STO+ 4
15:  22, 4;  RCL 4
16:  61, 26;  RTN

17:  61, 41, C;  LBL C
18:  33;  (
19:  22, 3;  RCL 3
20:  65;  ×
21:  22, 2;  RCL 2
22:  34;  )
23:  45;  ÷
24:  33;  (
25:  22, 2;  RCL 2
26:  65;  -
27:  22, 1; RCL 1
28:  34;  )
29:  74;  =
30:  14;  y^x
31:  22, 4; RCL 4
32:  15;  1/x
33:  74;  =
34:  21, 6;  STO 6
35:  26;  R/S
36:  33;  (
37:  22, 2; RCL 2
38:  65;  -
39:  22, 1; RCL 1
40:  34;  )
41:  55;  ×
42:  33;  (
43:  22, 6;  RCL 6
44:  65;  -
45:  1;  1
46:  34;  )
47:  45;  ÷
48:  22, 6;  RCL 6
49:  45;  ÷
50:  33; (
51:  22, 6;  RCL 6
52:  14;  y^x
53:  22, 4;  RCL 4
54:  65;  -
55:  1;  1
56:  34;  )
57:  51, 11;  x^2
58:  74;  =
59:  12;  e^x
60:  21, 5;  STO 5
61:  26;  R/S
62:  33;  (
63:  22, 1; RCL 1
64:  55;  ×
65:  22, 3; RCL 3
66:  65;  -
67:  22, 2;  RCL 2
68:  51, 11;  x^2
69:  34;  )
70:  45;  ÷
71:  33;  (
72:  22, 4; RCL 4
73:  55;  ×
74:  33;  (
75:  22, 1;  RCL 1
76:  75;  +
77:  22, 3;  RCL 3
78:  65;  -
79:  2;  2
80:  55;  ×
81:  22, 2;  RCL 2
82:  34;  )
83:  34;  )
84:  74;  =
85:  12;  e^x
86:  21, 7;  STO 7
87:  61, 26;  RTN


Example

Fit the following data into a Gompertz curve:
(1, 16)
(2, 18)
(3, 19)
(4, 25)
(5, 28)
(6, 29)
(7, 32)
(8, 36)
(9, 37)

First, order the data points. Second, divide the data into three equal parts. For this example, we have 9 data points. From our example:

16, 18, 19, 25, 28, 29, 32, 36, 37

is divided into:

Group I: 16, 18, 19
Group II: 25, 28, 29
Group III: 32, 36, 37

Initialize the program: XEQ A

Enter the data:
16 XEQ B, 25 R/S, 32 R/S
18 XEQ B, 28 R/S, 36 R/S
19 XEQ B, 29 R/S, 37 R/S

Calculate the parameters: XEQ C
b: 0.82711002676, R/S
a: 2.33690515E-1, R/S
c: 48.2137954914

The Gompertz Curve is
y = 48.2137954914 * 2.33690515E-1 ^ (0.82711002676 ^ x)

Predict the 10th point:
Key strokes: RCL 6, y^x ,10, =, RCL 5, y^x, LAST, ×, RCL 7
Result: 38.776391586



Source

HP-37E & HP-38E/38C: Marketing and Forecasting Applications Hewlett Packard. May 1979.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)