Post Reply 
(41C/CV/CX) Epidemiologic Programs for Computers & Calculators
04-26-2024, 02:40 PM (This post was last modified: 04-27-2024 03:09 PM by SlideRule.)
Post: #1
(41C/CV/CX) Epidemiologic Programs for Computers & Calculators
An extract from Epidemiologic Programs for Computers and Calculators, SIMPLE ALGORITHMS FOR THE REPRESENTATION OF DETERMINISTIC AND STOCHASTIC VERSIONS OF THE REEDFROST EPIDEMIC MODEL USING A PROGRAMMABLE CALCULATOR, AMERICAN JOURNAL OF EPIDEMIOLOGY, Vol. 123 No. 5, 1986, pages 905-915

   Two programs are described for the emulation of the dynamics of Reed-Frost progressive epidemics in a handheld programmable calculator (HP-41C series). The programs provide a complete record of cases, susceptibles, and immunes at each epidemic period using either the deterministic formulation or the trough analogue of the mechanical model for the stochastic version. Both programs can compute epidemics that include a constant rate of influx or outflux of susceptibles and single or double infectivity time periods. …

         MATERIALS AND METHODS
                     Equipment
   Programs were written for an HP-41CV programmable calculator (Hewlett-Packard Co., Corvallis, OR). The minimal system configurations enabling execution of the two programs are 1) the basic HP-41C calculator equipped with two HP-82106A memory modules or one HP-82170A Quad memory module, or 2) an HP-41CV or an HP-41CX calculator. Use of the HP-82182A time module enables generation of automatic time-dependent random number seeds. Although this would have represented a desirable feature for the stochastic version, we resorted to a keyboard-entered, user-chosen seed to reset the generator. The programs contain several instructions to allow printing of the output. We used an HP-82143A printer (Hewlett-Packard Co.) to obtain a permanent record of the results, i.e., frequencies of cases, susceptibles, and immunes at each epidemic period and a pictorial representation of the aligned balls in the trough. However, use of a printer is not mandatory since all results, except the trough picture, will be displayed in the calculator also. Unattended program execution is possible only with the printer present in the system. Use of the HP-82104A card reader is optional. …

         Description of the algorithms
   The two programs, REED and FROST, although totally independent with respect to register usage, flag control, and execution, share the same basic structure. Both programs are divided into two major routines: input and data processing. …

                                       TABLE 1
Operating instructions for programs REED and FROST in user mode

APPENDIX: PROGRAM LISTINGS


BEST!
SlideRule
Find all posts by this user
Quote this message in a reply
04-27-2024, 11:53 AM (This post was last modified: 04-28-2024 09:45 AM by Thomas Klemm.)
Post: #2
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
REED

This is the program REED for the HP-41C:
Code:
01*LBL "REED"
02 "REED-FROST"
03 ├" EPIDEMICS"
04 AVIEW
05 "<DETERMINISTIC>"
06 AVIEW
07 ADV
08*LBL A
09 1 E-1
10 STO 04
11 CLX
12 STO 05
13 STO 06
14 CF 00
15 FIX 3
16 1
17 TONE 9
18 "P? ="
19 PROMPT
20 -
21 STO 00
22 ARCL L
23 FS? 55
24 PRA
25 CF 29
26 FIX 0
27 TONE 9
28 "C0? ="
29 PROMPT
30 STO 02
31 ARCL X
32 FS? 55
33 PRA
34 TONE 9
35 "S0? ="
36 PROMPT
37 STO 03
38 ARCL X
39 FS? 55
40 PRA
41 TONE 9
42 "S. INFLUX? ="
43 PROMPT
44 STO 01
45 ARCL X
46 FS? 55
47 PRA
48*LBL 00
49 TONE 9
50 "INF. TIME? ="
51 PROMPT
52 ARCL X
53 FS? 55
54 PRA
55 ADV
56 2
57 X=Y?
58 GTO 01
59 CLX
60 1
61 X#Y?
62 GTO 00
63 SF 00
64*LBL 01
65 ISG 04
66 GTO 02
67 TONE 9
68 STOP
69*LBL 02
70 RCL 00
71 RCL 02
72 FC? 00
73 XEQ 03
74 Y^X
75 1
76 -
77 CHS
78 RCL 03
79 *
80 RND
81 "T="
82 ARCL 04
83 ├"  C="
84 ARCL X
85 RCL 06
86 RCL 02
87 FS? 00
88 ST+ 05
89 STO 06
90 RDN
91 FC? 00
92 ST+ 05
93 RDN
94 ST- 03
95 STO 02
96 RCL 01
97 ST+ 03
98 ├"  S="
99 ARCL 03
100 X#0?
101 GTO 04
102 ├"  I="
103 ARCL 05
104*LBL 04
105 FC? 55
106 PROMPT
107 FS? 55
108 PRA
109 RCL 02
110 X=0?
111 GTO 05
112 GTO 01
113*LBL 03
114 RCL 06
115 +
116 RTN
117*LBL 05
118 TONE 9
119 "END OF EPIDEMIC"
120 AVIEW
121 ADV
122 RTN
123*LBL B
124 CF 00
125 SF 29
126 FIX 2
127 END

And here the same program for the HP-42S:
Code:
00 { 302-Byte Prgm }
01▸LBL "REED"
02 "REED-FROST"
03 ├" EPIDEMICS"
04 AVIEW
05 "<DETERMINISTIC>"
06 AVIEW
07 ADV
08▸LBL A
09 1ᴇ-1
10 STO 04
11 CLX
12 STO 05
13 STO 06
14 CF 00
15 FIX 03
16 1
17 TONE 9
18 "P? ="
19 PROMPT
20 -
21 STO 00
22 ARCL ST L
23 FS? 55
24 PRA
25 CF 29
26 FIX 00
27 TONE 9
28 "C0? ="
29 PROMPT
30 STO 02
31 ARCL ST X
32 FS? 55
33 PRA
34 TONE 9
35 "S0? ="
36 PROMPT
37 STO 03
38 ARCL ST X
39 FS? 55
40 PRA
41 TONE 9
42 "S. INFLUX? ="
43 PROMPT
44 STO 01
45 ARCL ST X
46 FS? 55
47 PRA
48▸LBL 00
49 TONE 9
50 "INF. TIME? ="
51 PROMPT
52 ARCL ST X
53 FS? 55
54 PRA
55 ADV
56 2
57 X=Y?
58 GTO 01
59 CLX
60 1
61 X≠Y?
62 GTO 00
63 SF 00
64▸LBL 01
65 ISG 04
66 GTO 02
67 TONE 9
68 STOP
69▸LBL 02
70 RCL 00
71 RCL 02
72 FC? 00
73 XEQ 03
74 Y↑X
75 1
76 -
77 +/-
78 RCL 03
79 ×
80 RND
81 "T="
82 ARCL 04
83 ├"  C="
84 ARCL ST X
85 RCL 06
86 RCL 02
87 FS? 00
88 STO+ 05
89 STO 06
90 R↓
91 FC? 00
92 STO+ 05
93 R↓
94 STO- 03
95 STO 02
96 RCL 01
97 STO+ 03
98 ├"  S="
99 ARCL 03
100 X≠0?
101 GTO 04
102 ├"  I="
103 ARCL 05
104▸LBL 04
105 FC? 55
106 PROMPT
107 FS? 55
108 PRA
109 RCL 02
110 X=0?
111 GTO 05
112 GTO 01
113▸LBL 03
114 RCL 06
115 +
116 RTN
117▸LBL 05
118 TONE 9
119 "END OF EPIDEMIC"
120 AVIEW
121 ADV
122 RTN
123▸LBL B
124 CF 00
125 SF 29
126 FIX 02
127 END

This allows us to reproduce FIGURE 3:
Quote:Three examples of printed output from program "REED" which is based on the deterministic formulation. The three epidemics displayed differed in the magnitude of the p values: 0.02, 0.03, and 0.04, respectively.

REED-FROST EPIDEMICS
<DETERMINISTIC>

P? =0.020
C0? =1
S0? =100
S. INFLUX? =0
INF. TIME? =1

T=1 C=2 S=98 I=1
T=2 C=4 S=94 I=3
T=3 C=7 S=87 I=7
T=4 C=11 S=76 I=14
T=5 C=15 S=61 I=25
T=6 C=16 S=45 I=40
T=7 C=12 S=33 I=56
T=8 C=7 S=26 I=68
T=9 C=3 S=23 I=75
T=10 C=1 S=22 I=78
T=11 C=0 S=22 I=79
END OF EPIDEMIC


REED-FROST EPIDEMICS
<DETERMINISTIC>

P? =0.030
C0? =1
S0? =100
S. INFLUX? =0
INF. TIME? =1

T=1 C=3 S=97 I=1
T=2 C=8 S=89 I=4
T=3 C=19 S=70 I=12
T=4 C=31 S=39 I=31
T=5 C=24 S=15 I=62
T=6 C=8 S=7 I=86
T=7 C=2 S=5 I=94
T=8 C=0 S=5 I=96
END OF EPIDEMIC


REED-FROST EPIDEMICS
<DETERMINISTIC>

P? =0.040
C0? =1
S0? =100
S. INFLUX? =0
INF. TIME? =1

T=1 C=4 S=96 I=1
T=2 C=14 S=82 I=5
T=3 C=36 S=46 I=19
T=4 C=35 S=11 I=55
T=5 C=8 S=3 I=90
T=6 C=1 S=2 I=98
T=7 C=0 S=2 I=99
END OF EPIDEMIC



FROST

This is the program FROST for the HP-41C:
Code:
01*LBL "FROST"
02 "REED-FROST"
03 ├" EPIDEMICS"
04 AVIEW
05 "<STOCHASTIC>"
06 ├"<TROUGH>"
07 AVIEW
08 ADV
09*LBL A
10 1 E-1
11 STO 13
12 CLX
13 STO 07
14 STO 09
15 STO 10
16 STO 14
17 CF 00
18 CF 01
19 CF 02
20 CF 03
21 FIX 3
22 2
23 TONE 9
24 "P? ="
25 PROMPT
26 ARCL X
27 FS? 55
28 PRA
29 CF 29
30 FIX 0
31 /
32 2
33 -
34 RND
35 STO 04
36 TONE 9
37 "C0? ="
38 PROMPT
39 STO 06
40 ARCL X
41 FS? 55
42 PRA
43 TONE 9
44 "S0? ="
45 PROMPT
46 STO 05
47 ARCL X
48 FS? 55
49 PRA
50 TONE 9
51 "S. INFLUX? ="
52 PROMPT
53 STO 12
54 ARCL X
55 X#0?
56 SF 03
57 FS? 55
58 PRA
59 TONE 9
60*LBL 04
61 "INF. TIME? ="
62 PROMPT
63 ARCL X
64 FS? 55
65 PRA
66 1
67 X=Y?
68 GTO 05
69 CLX
70 2
71 X#Y?
72 GTO 04
73 SF 02
74*LBL 05
75 TONE 9
76 "SEED<=9999?="
77 PROMPT
78 ARCL X
79 FS? 55
80 PRA
81 ADV
82 1 E4
83 /
84 STO 08
85*LBL 06
86 FS? 49
87 OFF
88 "<"
89 FS? 55
90 ACA
91 RCL 07
92 RCL 06
93 RCL 05
94 RCL 04
95 STO 00
96 +
97 STO 01
98 +
99 STO 02
100 FC? 03
101 +
102 STO 03
103 ISG 13
104 GTO 08
105 BEEP
106 STOP
107*LBL 08
108 FC? 02
109 GTO 07
110 RCL 14
111 ST+ 02
112 ST+ 03
113*LBL 07
114 .003
115 STO 11
116 RCL 08
117 9821
118 *
119 .211327
120 +
121 FRC
122 STO 08
123 RCL 03
124 *
125 INT
126 1
127 +
128*LBL 09
129 RCL IND 11
130 X<>Y
131 X<=Y?
132 GTO IND 11
133 ISG 11
134 GTO 09
135 ">"
136 FS? 55
137 ACA
138 GTO 13
139*LBL 00
140 "*"
141 SF 01
142 1
143 GTO 10
144*LBL 01
145 "S"
146 1
147 ST+ 10
148 GTO 10
149*LBL 02
150 "C"
151 SF 00
152 1
153 GTO 10
154*LBL 03
155 "I"
156 1
157*LBL 10
158 ST- IND 11
159 ISG 11
160 GTO 10
161 FS? 55
162 ACA
163*LBL 11
164 FC?C 01
165 GTO 07
166*LBL 13
167 FC?C 00
168 GTO 12
169 RCL 10
170 ST+ 09
171*LBL 12
172 0
173 STO 10
174 RCL 01
175 RCL 02
176 X>Y?
177 GTO 07
178 RCL 09
179 RCL 14
180 RCL 06
181 FC? 02
182 ST+ 07
183 STO 14
184 RDN
185 FS? 02
186 ST+ 07
187 RDN
188 ST- 05
189 STO 06
190 RCL 12
191 ST+ 05
192 0
193 STO 09
194 BEEP
195 FS? 55
196 PRBUF
197 ADV
198 "T="
199 ARCL 13
200 ├"  C="
201 ARCL 06
202 ├"  S="
203 ARCL 05
204 FS? 03
205 GTO 14
206 ├"  I="
207 ARCL 07
208*LBL 14
209 AVIEW
210 FC? 55
211 STOP
212 CLD
213 ADV
214 RCL 06
215 X>0?
216 RCL 05
217 X>0?
218 GTO 06
219 TONE 9
220 "END OF EPIDEMIC"
221 AVIEW
222 ADV
223 RTN
224*LBL B
225 CF 00
226 CF 01
227 CF 02
228 CF 03
229 SF 29
230 FIX 3
231 END

It uses the printer's ACA and PRBUF commands, which are not supported by the HP-42S.
I haven't tested it yet, but I hope I didn't make any typos when transcribing from the original PDF.

These programs might have been useful four years ago.
We now also have other tools for modeling epidemics:




As always, thank you for your contributions.
Find all posts by this user
Quote this message in a reply
04-27-2024, 05:01 PM (This post was last modified: 04-27-2024 05:35 PM by Ángel Martin.)
Post: #3
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
I believe these programs were included in the EPIDEMICS module,
see the manual here
and the original thread on the SIR model subject.

This is the original posting of this article, also from SlideRule

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
04-28-2024, 02:52 AM
Post: #4
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
Sorry for the repost; I did a quick SERACH but missed the original post, somehow - great catch (very nice 41 & 42 listings) !

BEST!
SlideRule
Find all posts by this user
Quote this message in a reply
04-28-2024, 10:24 AM
Post: #5
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
(04-28-2024 02:52 AM)SlideRule Wrote:  Sorry for the repost

No worries about that. I probably missed your initial post.

(04-27-2024 05:01 PM)Ángel Martin Wrote:  I believe these programs were included in the EPIDEMICS module,

I downloaded the attachment in Post #6 but was not able to find the programs REED and FROST.
Then I downloaded the rom_files_240325.zip from the File Area of 41CL Calculator.
Finally I used rom2raw to extract the programs:

rom2raw -l EPIDEMIC.ROM > EPIDEMIC.txt

From this I extracted the files reed.txt and frost.txt in the attachment of this post.

This helped me to fix some bugs in my listings.
Meanwhile I've updated them in my previous post.

However, I also noticed some changes to the code in the EPIDEMIC module compared to the original programs.
Some of these are optimisations. I think they're fine.
Others are mostly cosmetic in the printed text.
Here I propose to consider them.

But I think the word TROUGH should stay as it is. That's not a typo.
And then there are clearly two bugs:
  • wrong label in GTO command
  • missing digit in constant
They are listed here. The first line as in the original and the second line as in the module:

REED
Code:
42 "S. INFLUX? ="
40 "S. INFLUX?  ="

FROST
Code:
06 ├"<TROUGH>"
04 ├"<THROUGH>"

37 "C0? ="
31 "CO? ="

76 "SEED<=9999?="
70 "SEED<=9999? ="

104 GTO 08
98 GTO 00

119 .211327
113 .21137


Attached File(s)
.zip  reed-frost.zip (Size: 1.99 KB / Downloads: 3)
Find all posts by this user
Quote this message in a reply
04-28-2024, 04:34 PM (This post was last modified: 04-28-2024 08:25 PM by Ángel Martin.)
Post: #6
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
Thomas, thanks for the thorough scrub - sorry you had to do all that conversion, I could have sent you the ROM files had I known you were doing this exercise.

You're right these two programs are not described in the manual I posted. I thought I had included the original pdf in the manual, will do that and send the updated copy for posting..

BTW in the module I have the correct GTO 08 in line 98...

Of all other glitches you report I believe the only one with more than cosmetic impact is the constant in the RNG routine, which is missing a digit. I should fix it in a forthcoming revision, thanks again.

Best,
ÁM

PS.- Updated manual and ROM blueprint included for your reference.

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
04-28-2024, 05:20 PM
Post: #7
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
This is a nice picture of a trough:
[Image: 440px-Kuh-Wassertrog.jpg]
This could even be in Switzerland.
Also it appears to be related to the German word Trog.

The paper Epidemiologic Programs for Computers and Calculators is included at the end of your excellent Epidemics ROM manual.
And the programs REED and FROST are part of the EPIDEMIC.ROM that I downloaded from Monte's site.

(04-28-2024 04:34 PM)Ángel Martin Wrote:  BTW in the module I have the correct GTO 08 in line 98...

I have the md5-sum 1d3812cb3d7b654125003cd438e5e1b8 for the EPIDEMIC.ROM.
Should I have used a different tool than rom2raw to extract the programs?
Find all posts by this user
Quote this message in a reply
04-28-2024, 05:39 PM (This post was last modified: 04-28-2024 08:32 PM by Ángel Martin.)
Post: #8
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
(04-28-2024 05:20 PM)Thomas Klemm Wrote:  This is a nice picture of a trough:
[Image: 440px-Kuh-Wassertrog.jpg]
This could even be in Switzerland.
Also it appears to be related to the German word Trog.

Really?? I thought that was a COW :-)

(04-28-2024 05:20 PM)Thomas Klemm Wrote:  The paper Epidemiologic Programs for Computers and Calculators is included at the end of your excellent Epidemics ROM manual.
And the programs REED and FROST are part of the EPIDEMIC.ROM that I downloaded from Monte's site.

(04-28-2024 04:34 PM)Ángel Martin Wrote:  BTW in the module I have the correct GTO 08 in line 98...

I have the md5-sum 1d3812cb3d7b654125003cd438e5e1b8 for the EPIDEMIC.ROM.
Should I have used a different tool than rom2raw to extract the programs?

Hmmm... not sure I sent the updated ROM to Monte yet, will make sure I do it next.

Here is the latest attached just in case

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
04-28-2024, 06:14 PM
Post: #9
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
I still get these lines in the FROST program:
Code:
97 ISG 13
98 GTO 00
99 BEEP
100 STOP
101▸LBL 08

But the trough is fixed:
Code:
04 ├"<TROUGH>"
Find all posts by this user
Quote this message in a reply
04-28-2024, 08:30 PM (This post was last modified: 04-28-2024 08:31 PM by Ángel Martin.)
Post: #10
RE: (41C/CV/CX) Epidemiologic Programs for Computers & Calculators
alright Thomas, you're correct... and so am I because if you single-step the code on the GTO 00 step you'll see it goes to LBL 08 (2 bytes ahead). Indeed there was a glitch in the source file, it had the correct jump distance but the wrong description - obviously that was a mistake that needs correcting in case somebody uses the program listing (or modifies it breaking the pre-compiled distances).
Thanks again - see attached


Attached File(s)
.zip  EPIDEMICS.zip (Size: 8.8 KB / Downloads: 6)

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
Post Reply 




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