computers and actuarial science s. benjamin jss 17 (2

61
COMPUTERS AND ACTUARIAL SCIENCE by S. BENJAMIN INTRODUCTION THE purpose of this article is to explore the application of com- puters to actuarial science. It is frankly a propaganda attempt to counterbalance the emphasis on data-processing applications which there has been in the past. I think that this emphasis has been an unfortunate mistake. Computers can be regarded as glorified desk calculators or high- speed punched-card machinery but this misses the real potential of the qualitative difference between computers and earlier machinery. This potential can only be realized when we learn to look at jobs 'computer-wise'. There is only one way to learn this and that is to learn how to programme and then to get down to some hard detail. Programming is to computers as probability is to actuarial science; without it there can be no understanding of any value, and only by acquiring some manipulative skill in the practice of its rules and logic can any of its implications be explored. The examination of our own scientific problems by computer methods would reveal the widest possible range of techniques, and would yield a broad basis of 'know-how' within the context of which most data-processing problems would appear as a simple, and often tedious, special branch. In fact this point can be taken further; the striking use of computers in data-processing comes from the introduction of a scientific programmed control at the centre of the processing system. As an example, most applications of computers which are given the title 'stock control' are really only 'stock recording'. Often, the greatest saving comes from programming into the recording system a continuous statistical analysis which controls the buying and allocation of stock. In practice there is a further disadvantage in starting with data- processing problems because it tends to lead to the ' appreciation 7 ASS 17

Upload: others

Post on 12-Feb-2022

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE

by

S. BENJAMIN

INTRODUCTION

T H E purpose of this article is to explore the application of com-puters to actuarial science. It is frankly a propaganda attempt tocounterbalance the emphasis on data-processing applications whichthere has been in the past.

I think that this emphasis has been an unfortunate mistake.Computers can be regarded as glorified desk calculators or high-speed punched-card machinery but this misses the real potential ofthe qualitative difference between computers and earlier machinery.This potential can only be realized when we learn to look at jobs'computer-wise'. There is only one way to learn this and that isto learn how to programme and then to get down to some harddetail. Programming is to computers as probability is to actuarialscience; without it there can be no understanding of any value, andonly by acquiring some manipulative skill in the practice of itsrules and logic can any of its implications be explored.

The examination of our own scientific problems by computermethods would reveal the widest possible range of techniques,and would yield a broad basis of 'know-how' within the contextof which most data-processing problems would appear as a simple,and often tedious, special branch. In fact this point can be takenfurther; the striking use of computers in data-processing comesfrom the introduction of a scientific programmed control at thecentre of the processing system. As an example, most applicationsof computers which are given the title 'stock control' are reallyonly 'stock recording'. Often, the greatest saving comes fromprogramming into the recording system a continuous statisticalanalysis which controls the buying and allocation of stock.

In practice there is a further disadvantage in starting with data-processing problems because it tends to lead to the ' appreciation

7 ASS 17

Richard Kwan
JSS 17 (2) (1963) 93-153
Page 2: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

94 S. BENJAMIN

course' attitude and a superficial interest in the 'hardware',e.g. the speed of the magnetic tape or the punched-card reader.This would be analogous to the early actuaries trying to developtheir science by listening to talks on how to lick one's thumb inorder to turn over the pages of a ledger more quickly. To continuethe analogy, an examination of the 'software', i.e. programmingfacilities and methods, would be equivalent to specifying thecontent and layout of commutation columns in early times.

This article is an attempt to influence the direction in whichactuarial effort in the field of computers is applied in the nearfuture. It is in fact likely to be out of date, one way or another,within a year or two. Just over a year ago the first full-bloodedcomputer programming course designed for actuaries was held—by the Students' Society. Thirty 'students', almost all Fellows,attended the course. Its effect was approximately to double thenumber of actuaries in this country who knew how to programme.A study group has now been set up and a second year's primarycourse is in progress at the time of writing. It would be fair toassume that before very long a sizeable proportion of the professionwill have a good working knowledge of computers.

If this broad basis of 'know-how' is developed we shall reachthe stage where almost all actuarial discussion will be influenced,directly or indirectly, by computer techniques. In some fieldsclose to actuarial work, both administrative and scientific, this hasalready happened. The growth of the techniques of buildingmathematical models to explore subjects which, before the war,would have been considered most un-mathematical, has gonehand-in-hand with the growth of the computer field. Life as-surance is probably the oldest mathematical model of them all—for no man knows when he is going to die—but it would be un-warranted to assume that this model will stand the test of timefuture, as well as the test of time past.

In the light—or dark—of these opinions, the following pagesexamine some specific examples of problems which could be tackledalmost immediately. In themselves these examples will not interesteveryone but they do illustrate computer techniques.

In view of what has been said above the first part is devoted to

Page 3: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 95a 'potted' programming course. It could be called an 'apprecia-tion course'—but it is to be hoped that some appreciation coursesare more equal than others. It is based on lectures given in thepast and attempts to give a fair idea of how calculating jobs, asopposed to data-processing jobs, are tackled on a computer. It iscommonly accepted that any programming course must be basedon an existing machine or programming scheme. The programmingscheme used here is one of the autocodes commonly used onFerranti computers, and my apologies are due to Ferranti for theway in which the following pages make the autocode seem extremelylimited in its facilities. It is, however, an extremely easy schemeto teach and, unlike some of the other autocodes, it is elementaryenough not to hide the basic principles of programming anymachine. It would be possible to describe the later examples interms which avoided reference to specific machines or codes, butmy own personal experience is that whilst this is excellent for peoplewho are familiar with programming it is quite useless to others.

Two warnings should be given. First, the' potted' programmingcourse really is potted; all 'ifs' and 'buts' have been omitted evenwithin the limited area it covers. Secondly, where costs are givenin one or two places, they are for illustrative purposes only.Generally speaking costs are similar as between one manufacturerand another for machines of comparable power.

The next section takes programming a step further by lookingat a specific type of job, namely straightforward valuation calcula-tions, and indicates how to specify a language in which this classof work can be expressed simply in terms which 'the machine'could understand. ' The machine', of course, is really a translatingprogramme lying inside the machine and a very brief indication isgiven of how such a translation programme can be worked.

The major part of the rest of the article is devoted to applyinga technique which is especially suited to computers to two actuarialproblems. The technique is 'simulation' and the two problemsare: (a) a traditional reversions problem which is too complicatedto handle by straightforward methods; and (b) the non-traditionalproblems of certain types of life reinsurance which are, however,coming into wider use. This includes an examination of group

7-2

Page 4: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

96 S. BENJAMIN

life assurance premiums with rebate, and data for an actualscheme are used to calculate premiums on various bases. Part of(b) was set as the final 'practical' on the Students Society Pro-gramming Course.

The 'examination paper' at the end is intended to peep at afew miscellaneous subjects. Unsatisfactory model solutions areavailable on request.

MICROSECONDS AND ALL THAT

A computer may be regarded as a set of boxes. These boxes maycontain (a) numbers, or (b) instructions.

(a) Numbers

There are two types of boxes which can hold numbers.

(i) n-boxesThese can hold only integers, positive, or negative. They are

numbered for reference purposes nO, n1, n2, . . . .

(ii) v-boxes

These can hold any type of number, positive, negative, integer,fraction or mixed (integer and fraction), e.g.

-10.2 +0.0003456 -1000.

For reference purposes these boxes are numbered

v0, v1, v2, . . .

The numbers held in the v-boxes are held in fact as two numbersin one box. Every number is expressed in a standard form

a x 106,

where 0.1 \a\ < 1, and a and b are both held in the one v-box,e.g.

-10.2 = -.102 x l02

+ •0003456 = .3456 x 10-3 is held as +.3456, - 3 ;

-1000 = -.1 x 104 is held as — •1, 4.

This is known as floating point working.

is held as -.102, + 2;

Page 5: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 97The standardized fraction is held to about 9 decimal places;

the exponent may take values in the range ± 80, That is numbersin the range 10-80 to 1080 can be held.

Obviously during most arithmetical working rounding errorswill occur.

There are operations of a counting nature which occur peculiarlyin computer programming and for these operations the n-boxesare usually used because there need be no fear of rounding. Thereis a further very important use for them, known as modification,which will be explained later.

Numbers in n-boxes can lie in the range ± 8000 approximately.

(b) Instructions

We shall be describing the exact form of the instructions shortly.Typical instructions are:

(i) Read in the next number punched on the paper tape whichis lying in the second paper-tape reader and place it in box v20.

(ii) Write, i.e. punch, the number in box v19 on to the paper-tape in the output punch—from where we can pass it straightthrough an automatic typewriter to type up the number punched.

(iii) Add the number in box v16 to the number in box v\7 andput the result in box v18.

The instructions lie one in each box and the computer normallyobeys them one after another.

The sequence of operations

The sequence of events when a programme is run is importantfor an understanding of the way a job must be organized. Thereusually comes a stage in the middle of a programming course whenthe students suddenly decide that nothing makes any sense at all.This is usually because they have forgotten the sequence of events,which is as follows:

(1) Punch the instructions on to paper tape; this forms the'programme tape'.

(2) Punch the data on to paper tape; this forms the 'data tape'(e.g. it might be a set of qx).

Page 6: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

98 S. BENJAMIN

(3) Place the beginning of the programme tape under thereading-head of the paper-tape reader and throw the switchmarked 'START'.

(4) The programme tape now starts magically to unroll andpass under the reading head. The instructions are read off thepaper tape and laid into the instruction boxes one after another.At this stage they are merely stored; they are not obeyed.

(5) At the end of the programme tape you will have punchedsomething which looks like an instruction but differs slightly inform. It is a ' directive' and not an instruction. All the time thatthe instructions are being read in, the computer examines them tomake sure they are instructions and not directives. A typicaldirective says: ' now start to obey my programme—which is nowstored—and start at instruction numbered 8'.

(6) As soon as the computer notices that it is dealing with adirective it does not store that directive but obeys it. This causesit to start obeying the stored instructions in sequence.

(7) It is a good idea to make the last instruction 'STOP', other-wise the computer will carry on and obey the rubbish left infurther instruction boxes by the last man on the machine. (Thelast man always leaves rubbish—carefully designed to give youthe maximum trouble.) Also if, say, your first instruction is'Read in a number from the data tape', and this is to be from thesame paper-tape reader as was just used to input programme,you will find yourself trying to change tapes within microseconds—an unrewarding exercise which can be avoided by making thefirst instruction 'STOP', 'STOP' really means 'pause until I throwthe switch marked 'RUN' and then carry on with the next in-struction'. The next instruction can be the 'read' instruction.

Paper-tape format

Most readers will be very familiar with punched cards, less sowith paper tape.

The characters available are the alphabet, the numerals, andsome special characters. Each character is represented by a setof holes across the width of the tape (a stripe) and the charactersfollow one another closely along the length of the tape.

Page 7: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 99

The special characters include

The character set varies from manufacturer to manufacturer andone of the reasons why one programming code may look wildlydifferent from another is merely due to the differences in thecharacter sets used (cf. the different printing sets on punched cardtabulators, some more limited than others).

There are other characters which have a special purpose. Thedata on the paper-tape can be printed by passing the tape backthrough the automatic typewriter. Hence there must be somethingon the tape to cause operations like 'return the carriage', 'roll upanother line' and 'leave a space'. These operations are obtainedby having special characters (i.e. 'stripes' of holes across the widthof the paper tape, in the same way as for any other character).There are, on the keyboard, keys marked A, B, etc.; 0, 1, 2, etc.;and also 'Sp ' (space), 'CR' (carriage return), ' L F ' (line-feed);and these are used when punching the paper tape. In fact thecharacters are printed on a separate wide roll of paper at the sametime as they are punched, i.e. a simultaneous 'hard-copy' is pro-duced, and the punching can be checked from this.

Thus,

CR LF + 1 • 2 Sp Sp - 0 • 1 CR LF 2

will produce + 1 . 2 _0.1

2

Numbers on the paper tape must be separated by CR, LF or Sp,and the computer uses this fact to determine when one numberfinishes and another begins.

The instructionsGeneral Format

Instructions are mostly of the typevO = v l+v2.

This means, take the numbers from boxes vl and v2, add themtogether and put the result in box vO.

( ) > >. , + — X / * -> = *

Page 8: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

S. BENJAMIN100

The format is that of an equation but strictly the meaning is thatthe result of the operation is to be left in the left-hand side.

Thus ©0 = ©0+©l

means take the numbers in boxes ©0 and ©1, add them together andput the result in box ©0. As a result ©0 will be changed; ©1 willremain unchanged.

Arithmetic instructions

Arithmetic instructions may take any of the following forms:

v0 = ±v1 ,

v2 = ±v10 ±v18,

v3 = ± v l l x v 1 9 ,

v17 = ±v25/v279.

At most two v's may appear on the right-hand side. Because ofthis limitation we cannot write

©0 = ©l+©2+©3 + ©4.We could do this by

v0 = v l + v 2 ,

v0 = v 0 + v 3 ,

v0 = v0+v4 .

Similar instructions are available for the n-boxes. Since thesecontain only integers there is a special instruction

n1 = v2*v3,

which leaves the remainder of n2/n3 in «1.Numbers may be written in the instruction on the right-hand

side instead of v's or w's,

e.g. v10 = -3/v8,

n1l = n1l+ 2.

(The last example will increase the number in n\ 1 by 2.)When writing programme it is of supreme importance to keep

to the rules of permitted formats. (Personally, I find that thefewer the number of different formats allowed the easier it is towrite programme; the restrictions are an advantage. One of the

Page 9: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE IOI

difficulties in using highly sophisticated programming languagesis that the format rules seem so loose—or complicated—thatimpermissible instructions are written all too easily. Theselanguages do, however, have other advantages.)

For present purposes, however, we need not give a completelist of formats for this particular programming 'language'.

Input and outputInput

Numbers may be read in by instructions of the type

©33 = TAPE.

This will read in the next number on the data-tape under thereading-head of the paper-tape reader and place it in box ©33.

©33 = TAPE 5

will read in the next 5 numbers and place them in boxes v33, v34,v35, v36 and v37 respectively.

Another useful 'read' instruction is, for example,

v10 = TAPE*..

This will read in numbers until a special marker (the letter 'L')is encountered on the paper tape. Also the numbers are countedas they are read in and the number of numbers read is left in thebox n0. The numbers are placed in boxes

v10, v11, v12 onwards.

Similarly, TAPEB, TAPEB 6, TAPEB* refer to the second paper-tapereader.

Output

Numbers may be punched (printed) by an instruction of the

type PRINT V15, 3085,

or PRINT ©15, 4103.

This causes ©15 to be printed. The number at the end of theinstruction is a code giving the printing style required. In thefirst digit 3 means 'print on a new line', 4 means 'leave one spaceand print on the same line, i.e. do not roll the carriage up'. The

Page 10: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

I O 2 S. BENJAMIN

next two digits (08 or 10 in the above examples) are twice thenumber of places to be printed before the decimal point; I haveno idea why the doubling is required—perhaps the originaldesigner has been laughing ever since. The last digit (5 or 3 above)gives the number of places after the decimal point. (No doublingis required here.)

Non-significant zeros at the beginning are replaced by spaces.There is rounding in the last digit. Thus, if

vO contains -123456999,

and vl contains 11.3599901,

and v2 contains 345.000002,the instructions

PRINT vO, 3064,

PRINT v1, 4064,

PRINT v2, 3064.(That is all specifying 3 places before and 4 places after the point)will output

•1235 11.3600,

345.0000,

i.e. there will be proper column alignment.If the number is too large for the printing style, the output will

do its best, viz. the number will be output in the form requestedfollowed by a decimal exponent, e.g. if

vO contains 12345.6789,the instruction

PRINT vO, 3042

(i.e. 2 before and 2 after the decimal point)will output

12.35 3,

meaning 12.35 x 10s.

This will show up on the printed page rather sharply because thelayout will be disturbed. Presumably if your programme givesyou a number larger than any you anticipated you would like tohave your attention drawn to the fact.

Page 11: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE IO3

Example. We can now try a real programme. Let us add twcnumbers together. (I gave up using this as a set demonstratiorbecause it always went wrong.) The steps are as follows:

(1) Punch our programme tape which looks like thisSTOP

vO = TAPE 2

vO = vO+vlPRINT vO, 3021

STOP

( ->0)(We discuss this below.)

(2) Punch the two numbers, say 1.1 and 2.2 to give us ourdata tape.

(3) Go to the machine. Place our programme tape under thereading head. Throw the START switch. Our programme is readin instruction by instruction and stored in consecutive instruction-boxes.

(4) At the end of the programme tape the machine finds( 0).

The innocuous-looking left-hand bracket ' ( ' makes this a directive,i.e. the machine stops storing instructions and obeys

0.

Jumping ahead in our explanation, this means go and obey thefirst instruction of my (stored) programme.

(5) The first instruction to be obeyed is STOP. This allows ustime to place our data tape (all two numbers) under the readinghead.

(6) We throw the switch marked 'RUN' and the computer carrieson to the next instruction which is

v0 = TAPE 2,

i.e. read in two numbers and place them in v0 and v\ respectively.(7) The next instruction

v0 = v0+vladds the two numbers together and leaves the answer in v0.

Page 12: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

S. BENJAMIN104

(8) The next instruction punches the number in vO on to papertape in such a way that when printed the number will appear ona new line, and will have one place before and one place after thedecimal point.

(9) The last instruction is STOP.

With luck the output will be 3.3.

Functions

Various special functions are available. Typical instructions arealmost self-explanatory:

vO = LOG v\

v2 = EXP v3

v1 = INT v2 (integer part)

v2 = FRAC v3 (fractional part)

etc.Labels and jumps

So far we have hardly done anything very exciting (except getthe correct answer 3.3 to our example). The idea of organizinginput and output from inside the machine is perhaps novel.

The real power of computer programming and its generalitywill only become apparent after we have introduced some othertypes of instructions.

So far we have said that instructions are obeyed one afteranother in strict sequence. This sequence can be broken as follows:

First, any instruction may be numbered or' labelled' for referencepurposes, e.g.

2) v0 = vl+v2.

This gives the 'label' ' 2 ' to the instruction

vO = v\+v2in our programme.

The labels do not have to be in order; any convenient numberingmay be used provided the same label is not used for more than oneinstruction—the computer will not even store a programme whichcontains this fault. Also in our example the use of the label 2does not imply that this is the second instruction in our programme.

Page 13: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE I05(Label '0 ' is however reserved for the first instruction, byconvention.)

Second, an instruction of the type

->2will cause the computer to jump to the instruction labelled 2.

Thus in the following part programme

vO = vl+v2,-+2v4 = v5 x v6,

2) v7 = v8+v9,vl = v2.

the instruction v4 = v5 x v6 would be jumped over and notobeyed.

Jumps may be backwards, e.g.4) v1 = v2+v3,

- • 4 ,would cause this pair of instructions to be obeyed repeatedly,i.e. the machine would go round and round a tight loop for ever.

This instruction is called an 'unconditional jump' and the aboveexamples do not make much sense as they stand. (The latterexample of perpetual 'looping' does however often occur in practiceby error, and many a programmer has happily watched the machinebeing very busy doing nothing useful in a perpetual loop becauseof faulty programme.)

Another type of jump instruction is the 'conditional jump'.A typical conditional jump is

-> 2, v8 > 7.

This reads: Go to instruction labelled 2 if the number in box ©8is greater than 7, otherwise carry on with the following instructionin the usual manner. Other typical conditional jumps are

-> 5, n1 3,->• 5, n1 = n2,

- • 6 , 8 v3(there is no character < or < on the keyboard).

Page 14: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

I06 S. BENJAMIN

Example. v\ and v2 each contains a number. Place the largerof the two in vO and square it. The following programme will dothis:

Notes

vO = vl-*• 1, vl > v2

Copy vl to vO anywayGo to instruction labelled 1 if vl contains the

larger, otherwise carry on in sequenceCopy v2 to vO (and over-write vl); this will

only be obeyed if the previous conditionaljump did not jump

v0 = v2

1) vO = vO x vO Square v0, result in vO.

Note that if vl = v2, the result will be (v 2)2 which in this examplemake no difference.

The following programme will also do the job but is not as neat:

Notes-*• 2, v2 > vlvO = vl• • 1 .

2) vO = v2,

1) vO = v0 x vO.

Unconditional jump required here

The flow-chart of this would be as follows:

?v2 > vl

no. .yes

v0 = v22)v0 = vl

1) v0 = v0Xv0

A pretty problem which usually appears in programming coursesis:

vl contains either 2 or 3; whichever it is, place the other in vO.Solution:

vO = 5 - v l .

Counting and loops

Consider the problem: given a in vl, form 1 + a5 in vO—usingrepeated multiplication, not logarithms.

Page 15: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE IO7

The programme may be written:Notes

v0 = 1v0 = v0 x v1v0 = v0 x vlv0 = v0 x vlv0 = v0 x vlv0 = v0 x vlv0 = 1+v0

This is clearly not the only way, or even the best, but it illustratesa repetitive pattern; the instruction

v0 = v0Xv1

appears five times. It is, however, possible to write the instructiononly once but make the computer obey it five times provided wemake use of the 'jump' facility (jumping back in fact) and do thecounting for the computer in our own programme. It is here thatthe n-boxes come into their own; they can be used to hold integersfor counting purposes and we need have no fear of rounding errors.

Consider the following:

vO= 1,

1) v0 = v0xv l ,

- • 1 .

This nearly does the job; the trouble is it goes on for ever. Con-sider the following, where we use the box nl to count:

n\ = 0v0 = 1

1) v0 = vO x vln1 = n1 + 1-+1, v1 4= 5vO = 1+vO

The conditional jump causes the required jump back to the basicinstruction

vO = v0 x vl

and the counter is stepped up each time round, taking successively

Starting valuev0 = 1 x av0 = a x av0 = a2 x av0 = a3'x av0 = a4 x av0 = l + a5

NotesClear the counterStarting valuear+1 = arxaAdd 1 to counterGo back if counter 4= 5vO = 1 +a5

Page 16: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

S. BENJAMIN108

the values 1 after the basic instruction has been obeyed once,2 after twice, . . . , 5 after five times; but now nl = 5 and the jump

->1

is not obeyed; the computer goes on to the last instruction,i.e. it 'falls out at the bottom of the loop'.

Modification

Consider the problem, given a1 in v1, a2 in v2, ..., a5 in v5,form 1 + a1a2a3a4a5 in vO.

Again we shall start by writing a simple programme:

This programme is clearly very similar to the one used to intro-duce counting and loops, with one subtle difference; at successiveinstructions we require to step along the boxes v\.. .v5. The wayin which we rewrote the former example, using a counter, wouldalso be suitable in this case if somehow we could cause the basicworking instruction to work like this, vO = vO x v (1 then 2 then 3then 4 then 5). We need a facility to allow us to alter the boxnumber written into an instruction. This facility is available;we are allowed to refer to boxes as, for example,

vn1,

v(8+n3).If a box is referred to in this general way, when the instruction isobeyed the computer will substitute the current value of the n-boxused, for example,

if nl = 5 at that point of time, vn1 is taken as v5,

if n3 = - 2 at that point of time, v(8+n3) is taken as v6.

NotesvO = 1vO = vO x vlvO = v0Xv2vO = v0 x v3vO = v 0 x v 4vO = v0xv5vO = 1+v0

Starting valuevO = 1 x a1vO = a t x a 2vO = a1a2xa3

vO = a 1 a i a 3 x a lvO = a1a1a3al x av0 = 1+a1a2a3a4a5vO = l+a^a^a^aia^

Page 17: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 109

Now consider the following programme, which is almostidentical to the one developed before:

Notes

n\ = 0 Clear the countervO = 1 Starting value

1) vO = vO x v ( l + n l ) vO = v0 X an

n\ = n\ +1 Add 1 to counter-> 1, nl = 5 Go back if counter = 5

vO = 1+vO vO = l+a 1 a 2 a 3 a 4 a 5

If we follow the programme through we find the desired effect isnow achieved. The first time instruction labelled 1 is obeyed«1 = 0 and the instruction is read as

vO = v0xvl .After the first jump back (by which time n1 has been increasedto 1) the instruction is read as

v0 = v0 x v2, etc.

Hence the instruction is 'modified'. This process is known as' modification'. Notice that box n1 is being used in a dual capacity,as a counter and as a modifier.

It is from the use of jumps, counters and modifiers that com-puter programming derives its generality. The power of thesemachines derives from the generality of the programmes and thespeed of operating on the instructions; the first is a property ofthe programmer, the second of the machine, but this distinction isoften not as clear-cut as it has been made to sound here.

In principle we have now covered most of programming. How-ever, the following examples may help to demonstrate the signifi-cance of some of the facilities.

Example A

Read in a table of qx where the youngest age is 20 and the oldest100, into boxes v120.. .v200. The table is terminated by thespecial warning character L.

Solution. The use of the marker L means that we can use theTAPE* instruction. The programme is

Notes

v120 = TAPE* After this «0 will equal 81.8 ASS 17

Page 18: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

110 S. BENJAMIN

Example B

As above, but there is no L at the end of the tape.Solution. We must now use a counter modifier. There are several

ways of doing this, e.g.Notes

Opening value of counter-modifierRead one numberIncrease counter-modifierConditional jump; the last jump back will

take place with n\ = 100.

Example C

This illustrates a more general way of inputting a table. A tableof qx has two numbers punched at the head of it, the youngest ageand the oldest age. At the end of the tape an L is punched. Writean input routine which reads the qx into the w-boxes in such a waythat qx lies in v(100+x:). Also incorporate a simple check on thenumber of qx read in.

SolutionNotes

nl = TAPE 2 Read 2 numbers; hence nl = youngest age,n2 = oldest age.

v(100+nl) = TAPE* Read numbers (i.e. qx) into boxes v(100 +youngest age), v(100 + next age), etc., untilL is reached. At this point nO = numbernumbers read in by the instruction

nO = nO+nl /Check that nO = oldest age —youngestn0 = nO-n2 age + 1-> 1, n0 = 1 Go to 1 if all O.K. otherwise see below

TEXTHARD LUCK, YOUR INPUT IS WRONG

1) Next instruction

Note, TEXT is an instruction to the computer to print out themessage on the following line (which itself is not, of course, aninstruction—at least, not to the computer!).

n\ = 20

1) v(100+nl) = TAPEn1 = n 1 + 1-»• 1, 100 > n1

Next instruction

Page 19: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE I I I

Example D

Given a table of qx stored so that qx lies in v(100+*) read in anage from the paper tape input and print out the correspondingvalue of qx.

SolutionNotes

n\ = TAPE n\ = age xPRINT V(100 +n1), 3005 Print qx on a new line with no places before

and 5 places after the decimal point

Note. This process is called' table look-up'—for obvious reasons.Clearly this is important in actuarial work. What is less obvious isthat most 'data processing' is merely a process of table look-up.

Example E

As above, but do it for a series of ages. These ages are punchedon the input tape and end with a negative number—a dummyage—which is to act as an end-marker.

Notes2) n1 = TAPE

- • 1 , 0 > n1PRINT V(100 + nl), 3005->2

1) Next instruction

Example F

A table of qx for males is stored so that qx lies in v(100+x).The corresponding table for females is stored so that qx lies inv(200+x). The data tape contains groups of four numbers whichare the data for the members of a scheme.

The first number is the member's scheme number.The second number is the member's sex; male = 1, female = 2.The third number is the member's age.The fourth number is the member's sum assured.The end of the scheme is denoted by a dummy member

containing four — l's.Find the expected claim for males and females separately.

8-2

n\ = age[Jump if end, otherwise print and then-j return to read next age

Page 20: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

S. BENJAMIN1 1 2

Solution

Flow-chart: clear two boxes for Σ,Sqm,Σ Sqf say v1 and v2.

Read a member's data? data = - 1

Yes/\No

Print totals Put n10 (say) = 100 x sexLookup v(n10 +age), i.e. qx

Form sum assured x qx

Add Sqx into v(sex), i.e. v1 or v2i

Programme:Notes

v1 = 0 Clear for ΣSqm

v2 = 0 Clear for ΣSqf

2) n\ = TAPE 3 n\ = member's number (not used)n2 = sex (1 or 2)n3 = age

vO = TAPE vO = S

1, nl = — 1 Jump if endnl0 = 100 x «2 100 x sexn10 = n10 + «3 100 x sex + age is the number of the v-box

which contains qx

vO = vO x vnlO Put Sqx in vOvn2 = vn2 + vO Add Sqx, into v(sex), i.e. required total->• 2 Go back for next member

1) PRINT v1, style Note: these instructions will only be reachedPRINT v2, style when the fifth instruction, -> 1, nl = — 1STOP finds a negative'member'

Modified jumps

We are allowed to write a more general type of jump instruction,

e.g. ->n1,->n2, v3 > 0,

which will be interpreted according to the current value of then-box. Thus

if nl = 21, ->nl is interpreted as ->21if n2 = 30, -» n2, v3 > 0 is interpreted as -- 30, v3 > 0.

If we have forgotten to set the n-box beforehand to the value werequire, the computer will gaily use the malevolent rubbish leftthere by the last man on the machine.

Page 21: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE " 3The main use for this facility is explained in the next section,

dealing with subroutines. However, the following example of asimple data-processing job illustrates a common requirement inthis type of work.

Example G

The data-tape is the same as that of example F except that afifth number, a code, is included with each member. This codecan take values 10, 13 and 16 only. According to the value of thecode do the following (rather useless) things:

If code = 10, subtract 2 from the age, and print the member's(new) data.

If code = 1 3 , double the sum assured, and print the member's(new) data.

If code = 16, merely print the member's data.

Solution. We use the trick of labelling the first of the group ofinstructions which deals with the case 'code = 10' with a 10;similarly for 13 and 16.

Programme:Notes

1) Ml = TAPE 3vO = TAPEn4 = TAPE

18, nl = - 1-»-n4

10) n3 = n3 -2- • 1 6

n1 — member's no., til = sex, «3 = agevO = sum assuredn4 = code-> 18 if end of tape, otherwiseGo to instruction labelled with code value

Subtract 2 from age and go to 16

13) v0 = 2 x v016

[Double sum assured and go to 16

16) PRINT Nl, stylePRINT N2, stylePRINT N3, stylePRINT vO, stylePRINT N4, style->1

Print

Go to read next member if not end, otherwiseStop18) STOP

Note. The 16 after vO = 2 x v0 is unnecessary; the computerwould automatically run on to the next instruction which in thiscase is label 16.

Page 22: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

114 S. BENJAMIN

Subroutines

Most programmes of any length (say six instructions) arewritten from the middle outwards. It is in fact a little awe-inspiringto watch a very experienced programmer tackle a new problemby starting at the beginning and working steadily through.Fortunately there is a technique available which allows a problemto be broken down into logical parts; each part can be programmedseparately and the parts can be joined together later. Each part,consisting of a group of instructions, is called a 'subroutine';these subroutines are then linked together by other instructionswhich may also do further work between the subroutines. A sub-routine is nothing more than a convenient group of instructions.

Example. Write a group of instructions to do the following job:given Nx lies in v(100+x),x == 10, . . . ,99, form ax in vO; assumethat * is given in n\ and t in n2. Do not destroy n1 and n2.

Programme:

Note. n3 and v1 have also been used.Now it is very common when writing a programme to find that

we wish to use a subroutine again and again. Thus if we call theabove group of instructions 'subroutine A' a full actuarial pro-gramme might look like this.

n3 = nl+n2vO = v(100 + nl)-v(100 + n3)v1 = v(100 + nl)-v(101+nl)v0 = v0/v1

Notesx + tNx — Nx+t in vODx = Nx-Nx+1 in vldx.ji in vO

Notes

Introductory instructions (say)

Subroutine A

Other instructions (say)

Subroutine A

Totalling instructions (say)

STOP

Page 23: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 115We can avoid writing the subroutine into the programme morethan once by two simple but neat tricks.

(1) Take the subroutine out and put it say at the end of theprogramme. By giving a label, say 10, to the first instruction ofthe subroutine we can reach it any time with a jump instruction

10. At this stage the programme would look like this:

Notes

— Introductory instructions

-> 10 Go to subroutine A

— Other instructions

10 Go to subroutine A

— Totalling instructions

STOP End of ' master' programme

(2) Clearly this programme is incomplete; we jump successfullyto the subroutine the first time but we never return. We need a' link' back to the main programme. In fact we need a jump-backinstruction at the end of the subroutine. However, the second timewe use the subroutine we need to jump back to a different pointfrom the first time, i.e. we need a variable jump. The modifiedjump, e.g.

will do just this job provided we arrange that each time we wantto use the subroutine (a) we label the instruction we want to comeback to, and (b) we set n10 equal to this label before we jump tothe subroutine.

The programme now looks like this:Notes

— Introductory instructions as before

10) n3 = nl+n2v0 = v(100 + nl)-v(100 + n3)vl = v(100 + nl)-v(101+nl)v0 = v0/vl

Subroutine A with the firstinstruction labelled 10

-^n10,

Page 24: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

n 6 S. BENTAMIN

NotesnlO = 1 Set (link) value of «10 equal to the

label of the return point10 Go to subroutine.

1) — Other instructions with the first— instruction labelled; this label was— the value to which n10 was set for— return purposes.nl0 = 2 Set new (link) value of nl0- 10 Go to subroutine.

2)' Totalling instructions with thefirst instruction labelled

STOP End

10) n3 = n l + n 2vO = v(100 + n l ) - v ( 1 0 0 + n3) Subroutine A with first instruc-v1 = v(100 + n1)-v(101 + nl) > tion labelled 10 and return linkvO = v0/v1 added, i.e. 10.n10

Library subroutines

It is common in programming to have available a library ofuseful, general purpose subroutines; indeed programming wouldbe extremely laborious without this facility for using the previouswork of other people and oneself. A library is usually usedwithout worrying about the inner workings of the subroutineitself. However, it is essential that a full specification of the sub-routine be given if it is to be used properly by others—and evenoneself after all the cunning tricks used have been forgotten.

For the above subroutine the programme would be:10) n3 = n l+n2

vO = v(100 + n1)-v(100 + n3)v1 = v(100 + nl)-v(101+nl)vO = v0/v1-•nlO

The specification would read as follows:Title Form single-life annuity.Process Forms ax.^ from table of Nx.Storage Uses «1, n2, n3, nl0, n0, v1, v100-v199; label 10.

2) Totalling instructions with thefirst instruction labelled

STOP Endn3 = n1+n2vO = v(100 + nl)-v(100 + n3)v1 = v(100 + nl)-v(101 + vl)vO = v0/v1->n10

Subroutine A with first instruc-tion labelled 10 and return linkadded, i.e. -> n10.

Page 25: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 117

Use The subroutine uses a table of Nx stored inv100-v199so that Nx lies in v(100+X).x must be set in n\ and t in n2 before entry.n\ and n2 are not destroyed.dx:J\ is left in vO on exit.v1 is used during the calculation.The link is set in n10.The subroutine is entered by -> 10.

Notes. There is no check against using ages above 99; Dx isformed from Nx — Nx+1 hence the maximum value of x +t is 98.(As usual the specification requires more space than the programmeitself.)

DirectivesWe described a 'directive' at the beginning as something which

appeared on the programme tape and looked like an instructionbut was not. The only example given so far has been

(-*0).The first thing that happens to a programme is that it is merely

read into the machine and stored in successive instruction boxes.In practice it is necessary and convenient to interrupt this processand get the machine to do other things. Thus we do not want itto keep reading and storing programme tape for ever. Thedirective ( -> 0), distinguished by the left-hand bracket, says ' stopreading and storing programme and obey me now', i.e. jump tothe first instruction. This is the way we cause the machine tostart obeying stored programme. If we wished to start at instruc-tion labelled 8 then the directive ( -> 8) would do the job.

There is usually, in any programming scheme, a list of directivesand they need not look like instructions. The warning character Lwhich is used with the TAPE* instruction is an example. However,their various uses are difficult to explain within the context ofautocode.

How it is doneIt is hoped that the reader who had no knowledge of programming

before will have gained a fair idea from the preceding sections ofhow its basic rules work.

Page 26: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

n 8 S. BENJAMIN

The main criticism of the explanation given is that we havetended to talk from time to time as if the computer did quitecomplicated things, such as inspect the programme tape whilstreading it to see if a directive was coming. The computer itself,in spite of its mass of expensive electronics cannot do anythingas sophisticated as read a tape with intelligence. There has to bea programme already in the machine to do the reading. This hasto be a well-written general purpose reading and preparing pro-gramme. Throwing the START switch in fact calls in this basicreading programme which then starts to read in the characters onyour programme tape, using the directives to jump to differentparts of itself, analysing the sequence of characters as it readsthem, assembling your instructions and laying them into instruc-tion boxes in the way the engineers demand. This basic programmeis so important that quite often the engineers arrange that itcannot be over-written by mistake.

The basic programme is put in by the engineers.

Compilers and interpreters

The symbols, and the rules by which you are allowed to putthem together, constitute a programming 'language'. The auto-code used here to describe programming is one such language.The language of the machine itself is a compromise between thedemands of the programmers and the engineers who design it, andprice. It is invariably in a highly coded form which is not im-mediately intelligible and the instructions are more basic but moregeneral than those of autocode. The arithmetical instructions areusually included, but even there the operations of multiplicationand division may not be given and may have to be programmedby sub-routines. There would certainly be no TAPE* instructions,but there would be facilities for shifting separate characters aroundinside the boxes. To write programmes in machine language istedious in the extreme, and as programmers in general becamemore and more fed up with it they started to design and writemore and more useful basic reading and assembling programmes,which would read programmes written in different and moresimple 'languages' and convert them into machine language or

Page 27: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 119

interpret them for the user. The rules of these languages (andthere are several of them) must be very closely observed by theuser, although a good designer will incorporate checks in hisinterpreting programme to see that his conventions are obeyed.Thus in autocode you can write

v(l + nl),but you cannot write

v(nl +1).

The interpreting programme, written in machine language, readsin the characters of your autocode programme one at a time andexamines them. It will accept the v, and will accept a left-handbracket immediately following, but it will not accept the character nto follow; on finding the n it will jump to a part of itself whichprints out rude messages.

There are two main ways in which these interpreting programmescan work.

(1) They can read your symbols and convert them into machinelanguage. Then the machine language translation of your programmeis obeyed by the machine. This translating programme is knownas a 'compiler'.

(2) They can read your symbols and merely lay them in thestore more or less as they stand. The interpreting programme canthen pick up groups of symbols representing your instructionsand interpret them as they stand without translating them directlyinto equivalent machine instructions.

There are advantages and disadvantages to both methods. Thedisadvantage of a compiler becomes apparent when somethinggoes wrong with your programme, because it may be, and usuallyis, quite difficult to relate the translation to your original instruc-tions, and in general the art of writing compilers is not yet ad-vanced enough to dispose of this difficulty. An 'interpreter' onthe other hand is, at any one time, carrying out the operationsrequired by one autocode instruction and it is usually easy to findout which.

The advantage of a compiler is that the translated programme isthen carried out at full speed. With an interpreter, on the other

Page 28: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

I2O S. BENJAMIN

hand, the whole process of interpreting is carried out afresh witheach autocode instruction. Thus to add 100 numbers together

MI = 1

1) vO = vO+vnl

nl = nl + 1

1, 100 > nl

the loop of three instructions is obeyed 99 times. An interpreterwould thus have to process the same three instructions 99 times.Furthermore, the interpreter must, of course, be in the machineall the time, taking up space. The compiler, once it has carriedout its translation, can be removed, or overwritten.

The autocode used in these notes is in fact run on one machineby compiling, and on another by interpreting. The language itselfremains unchanged.

TOWARDS AN ACTUARIAL AUTOCODEThere is no reason why we should not have an actuarial auto-

code, and the following notes are intended to indicate briefly theway in which a possible language could be explored with a viewto laying down a full specification.

Let us write our interpreting programme in autocode. This hasthe disadvantage that we shall be restricted to numeric charactersand it is also likely to be slow in operation, but for present purposesthis does not matter.

Consider a typical set of valuation instructions as we hand themto our clerical staff:

Age 11-70:(1) = sum assured,

(2) = Ax,

( 3 ) ( l ) x ( 2 ) .

In computer terms these mean:(1) Read in a column of 60 numbers; they will be treated as

sums assured running from age 11 to age 70.

Page 29: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 121

(2) Read in a column of 60 numbers; they will be treated assingle premiums running from age 11 to age 70.

(3) Form a third column of numbers by multiplying corre-sponding numbers in columns (1) and (2).

Hence our interpreting programme must be able to carry outoperations of this form, preferably allocating the boxes itself, andcertainly 'remembering' how the boxes have been allocated. Inorder to do this the interpreting programme must have someinstructions to obey, and a format for the instructions must bedesigned. Furthermore, any coding we decide upon must bepurely numerical. A typical actuarial autocode instruction couldtake the following shape, e.g.

a b c d e f00 3 1 2 11 70

i.e. it consists of 6 numbers a.../ in a line. These will be used asfollows:

(c) This is the number of one of the columns to be operated on.(d) This is the number of the other column to be operated on.(b) This is the number of the resulting column.(e) This is the first age in the columns.(f) This is the last age in the columns.(a) This is to be interpreted as a function according to a given

code e.g.00 means add i.e. (b) = (c) + (d)

01 means subtract (b) = (c) — (<d)

02 means multiply (b) = (c) x (d)

03 means divide (b) = {c)l(d)

Other functions with appropriate formats will be needed to readand write, e.g. 20 4

means 'read in the next column from paper tape; we shall referto it in future as column (4); the tape is headed with the first andlast age from which the range is to be picked up automatically'.

Also perhaps 21 4 g

could mean 'print out column (4) in style g'.

Page 30: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

122 S. BENJAMIN

The interpreting programme will read these instructions by a

- • n l

i.e. it will read the function number and jump to the instructionwith the same label number. The interpreting programme willbe written in the form of subroutines covering the operationsrequired by each function. Provided the first instruction of eachsubroutine is labelled appropriately the function will be 'obeyed'.

So far this is similar to the special autocodes which are widelyavailable for calculations with matrices. It is, however, usuallyawkward in these schemes to start at any age other than zero.Also the simple list of functions 00 to 03 given above will have tobe extended to carry out the operations on columns peculiar toactuarial work.

One organizational feature of value can be suggested at theoutset. Frequently used commutation columns could be held ona library tape for common use. These could be given numbersover 1000 and a printed reference list made available to all users.It would be part of the job of the autocode to inspect the programme,note the column numbers over 1000, pick them off the library tapeand lay them into the machine ready for use.

We shall want the autocode to arrange its own space inside themachine. Techniques for writing programmes which organizethe internal storage of the machine have been developed veryconsiderably over the last few years. Unfortunately, the compiler-writers, who are so adept at communicating with the machines,are singularly inept at explaining their methods.

Basically, however, it is necessary to set up a dictionary in whichto place entries referring to the whereabouts of the data. Toallocate boxes inside the machine to the columns we need adictionary, each entry of which contains at least four items. Thesewould be: (i) column number, (ii) first age, (iii) last age, (iv) thenumber of the v-box in which the first number in the column isheld.

These entries must be formed, by programme, whenever anew column is read in, or whenever a new column is formed by

method such as this: n1 = TAPE

Page 31: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 123

arithmetic on existing columns. A moment's thought will showthat items (i), (ii) and (iii) will always be available at this stage.Since the length of a column is

last age - first age +1

we can always find the position of the next empty w-box, whichwill be item (iv) for the next column introduced.

This dictionary, however, itself occupies space, so we need adictionary of the dictionary. At least two entries are required inthis:

(a) the number of the next v-box which is free to receive thenext dictionary entry (this must be stepped up by 4 eachtime), and

(b) the number of the next v-box which is free to receive acolumn. This is useful but not absolutely necessary.

Generally a sophisticated autocode will be using dictionaries ofdictionaries to a considerable depth.

Good programmers would require approximately one to threeman-years of effort to get a really useful actuarial autocode intooperation. The profession has been 'exposed' for, say, 8000 man-years to date?

MONTE CARLO METHODS

Consider the following problem. In a throw of two dice, what isthe probability that the sum of the two is 7?

A simple application of probability theory gives the answer 1/6.We could of course experiment with two real dice and throw

them repeatedly. We could also simulate this experiment withoutthe dice if we had a table of random numbers. By taking a table ofrandom digits and ignoring the digits 0, 7, 8, 9 we could treat pairsof consecutive digits as if they were the result of a throw. Bycounting the number of times a pair added up to 7 out of a largenumber of pairs we could approximate to the answer required.A knowledge of statistical theory—admittedly more than sufficientto answer this problem in the first place—would also enable usto estimate a confidence interval for the result.

Page 32: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

124 S. BENJAMIN

The method of simulating a probability situation by usingrandom numbers is known as the Monte Carlo method. Themethod has been successfully applied to non-probabilistic pro-blems, but we shall be concerned with actuarial applications whereprobability is involved, and the situation to be analysed is toocomplicated for traditional methods.

Most useful applications of the Monte Carlo method requirethe speed of a computer in order to carry out the simulation a largenumber of times in a usefully short period of time. Its strengthlies in the fact that it is a numerical method but this is also itsweakness; it may fail to give any general insight into the problem.

Let us consider a few simple actuarial examples. In the aboveexample the appropriate way to use the random numbers wasobvious; sometimes it is less so.

Given a table of lx find the value of e50 say. We shall use thefact that the probability of dying aged 50 +t last birthday is

Hence if we take a fraction/at random in the interval (0, 1) theprobability that

is the probability of death at age 50 +t last birthday.The following process will estimate e50:Use the table of random digits as groups of say five consecutive

digits with a decimal point assumed at the beginning of eachgroup, e.g. .12345, .09876, etc. These will be our random fractionsf', f"t etc. Form f'l50, then search down the lx table until somel50+t.( is found such that f'l50 lies between l50+t and l50+t+1, i-e.

l50+1 ^ f ' l 5 0 > l50+l+1

Then this value of t, say t', is our first estimate of e50. Repeat theprocess with «, to obtain t" and so on. The average value oft', t", ..., etc. from a large number of repeats will give an estimateofcjo-

Suppose we wish to estimate a50. We proceed as before and use

Page 33: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 125interpolation (first order, or higher) to find l50+t+e, where e is afraction of a year, such that

We then take

as our first estimate of a50. Our final estimate of a50 will be theaverage of a large number of annuities-certain formed in this way.

In the above examples we have implicitly assumed that therandom numbers are uniformly distributed in the relevant range.This is important and the regular users of Monte Carlo techniquesdevote a great deal of effort into justifying the randomness, theuniform spread, the independence, the lack of cycling, etc., etc.,in the numbers they use. We shall not consider this subject here.

Unfortunately digital computers cannot be programmed toproduce random numbers in the way that a special purposeelectronic machine such as ERNIE will do, and much ingenuity hasbeen devoted to developing essentially arithmetic methods ofproducing sequences of numbers which are sufficiently random.On a computer it is considerably more convenient from the pointof view of storage and speed to use one of these methods ratherthan to try to store a prepared book of random numbers.

As an example of such a method, consider the processxn+1 = remainder (8xn/ll).

Taking x0 as 10 say, we have the sequence 10, 3, 2, 5,7, 1, 8, 9, 6,4, and the cycle repeats. If fractions inside the range (0, 1) arerequired then each of these can be divided by 11.

However, some experimentation soon shows that the constantsmust be chosen quite carefully, in order to avoid short cycles,monotonic increasing or decreasing values, going to zero andstaying there, etc., etc.

The following is a standard subroutine for generating pseudo-random numbers taken from the library of a well-known computer:The method is given by the congruence

xn+1 = kxn(mod. 231-l),where xn+1 is the smallest positive integer satisfying the con-gruence, and

k = 455, 470, 314 = 1313 (mod.23 1-l).9 ASS 17

Page 34: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

126 S. BENJAMIN

x0 is an arbitrary starting number, preferably a positive integerof the order of 109 but less than 231 — 1. The sequence is repeatedafter 23 1 -2 = 2,147,483,646 steps.

A random fraction can be obtained by dividing xn by 231 — 1.' Clearly' this method is likely to produce a sequence of usefully

random numbers, depending on the idea that the constant multiplierand divisor at each stage are prime to each other, and the re-mainder—which is used as the random number—must be lessthan the divisor.

This method cannot be used with floating point numbers be-cause rounding errors will not hold the required integers tosufficient accuracy. (If the n-boxes had sufficient capacity onecould use them.)

A method of producing pseudo-random fractions in autocode,developed for my own purposes, is as follows:

(1) start with a fraction which is pretty horrible—e.g. thefractional part of A/2;

(2) multiply it by 10 repeatedly until it is greater than 1000;the v-box is now holding a number with 4 places before thedecimal point and 5 after;

(3) take its square root (leaving 2 places before the point and7 after);

(4) take the fractional part of this as the next random fractionand go back to (2).

The programme looks like this:

vO = SQRT 2

vO = FRAC vO

is set early on in the programme. The subroutine to generate apseudo-random fraction is

1) vO = vO x 10

-» 1, 1000 > vO

vO = SQRT v0

vO = FRAC V 0

- > n l

Page 35: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 127

and it is entered by setting the link nl and then jumping to label 1.On exit the fraction is found in vO.

A few simple tests on the first thousand fractions generated bythis method showed them to be adequate, but the method isdefinitely not recommended for examination purposes. It is alsorather slow.

A problem in reversions

Before proceeding to our main example we shall treat brieflya particular problem which is a simple extension of the examplesgiven above; it is a familiar actuarial problem in reversions basedclosely on a real case.

A fund is to be divided between six life tenants and a reversioner.The size of the fund, the age and sex of each life tenant are known.The basis is to be a(55) f and m mortality, 3£% net interest.Income from the fund is to be taken as 8 times the capital value.The terms of the will give priority to two particular life tenantsA and B whilst they are alive. Briefly A is to receive ,£306.25 perannum (£500 per annum net of tax) as a first charge on theincome of the fund, then B is to receive £306.25 per annum andthe remainder is to be shared equally between all the remainingsurviving life tenants, including A and B. If at any stage there isinsufficient income these priorities must still be observed. Ateach death the fund is to pay estate duty. The rate of duty fromthe standard Estate Duty Table is based on the sum of

(i) a proportion of the fund which equals the proportion oftotal fund income which was being received by that lifetenant immediately before her death, and

(ii) her other estate ('free estate').

If, however, her 'free estate' is less than £10,000 it is not addedin. (The 'free estate' of each life tenant is known.) The amountof estate duty is found by applying the rate to the above proportionof the fund. It is required to find the value of each life tenant'sinterest, the value of the reversion and, as a check, the value of thetotal estate duty paid.

This problem virtually defies treatment by traditional methods.9-2

Page 36: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

128 S. BENJAMIN

A brief description of its treatment by the Monte Carlo techniqueis as follows:

Let the life tenants be A, B, C, D, E, and F. Let their ages bea, b, c, d, e, f. Take six random fractions and, as explained above,apply them to la, lb, ..., lf to find the times to death, includingfractions of a year by interpolation in the lx tables (m or f). Letthese survival times be ta, tb, . . . , tf. Sort them into ascendingorder, say tlt t2, . • •, t6, remembering which relates to which lifetenant. The operation of the fund in this particular case maynow be followed through in detail, sharing the income accordingto the rules, levying estate duty at each particular death and leavinga final reversion. The values of the income to each survivorbetween successive deaths may be found by using factors

The values of estate duty at successive deaths require the factors

and the value of the reversion is found by using v*». Repeat thiswhole process a large number of times and find the average ofeach of the required values. The ratios between these averagesmay be used to express the answer in terms of relative proportions.

This problem was programmed in Autocode. Unfortunately ithas been run only on a machine which operates this Autocoderather slowly, and each simulation took nearly 2 minutes (about2000 three-address floating-point instructions obeyed from awritten programme of 450 instructions). At the end of ten simula-tions the results shown in Table 1 were produced.

From inspection of the coefficients of variation one wouldexpect 1000 simulations to give the required relative proportionsto a sufficient degree of accuracy for practical purposes. (It isalready clear that a great deal of estate duty is involved.) Themost powerful machine in existence today, the Atlas at ManchesterUniversity, would carry out 1000 simulations in approximately5 seconds at a nominal cost (without handling charges) of £1.

There is not much difficulty in programming this problem,although the programme is long enough to require careful re-cording of which numbers lie in which box, etc. Perhaps the only

Page 37: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 129

Table 1

Size of fund =£ 50,000. Initial income = £1,720.07 p.a.(1)

Average value of:(i)(ii)(hi)(iv)(v)(vi)(vii)(viii)(ix)(x)

Income to AIncome to BIncome to CIncome to DIncome to EIncome to FReversionEstate dutySum of (i) -(vii)Sum of (i)—(viii)

Standard

(0(11")(iii)(iv)(v)(vi)(vii)(viii)

£4604.8316961.9331567.7352386.4886247.9724503-8399823.318

13903.88436096.11650000.000

(4)

deviation of:

2463.7524184.749750075

2641.7012848.3153090.3222026.8431959.965

(2)As proportion

of (x)0092100139240031350.047730124960090080196470.27808

(5)Coefficient of

variation= (4)/(l)

0.535040.601090.478451.106940.455880.686150.20633014097

(3)As proportion

of (ix)0.127570192870043430066110173090124770.27214

programming technique used which has not been explainedearlier is that required by the sentence 'Sort ta, tb, ..., tf intoascending order, say tlt tit . . . , te, remembering which relates towhich life-tenant.'

A simple method of sorting a few items is that of comparingpairs and inverting them if necessary. Thus, compare ta with tb

and invert them if ta is greater than tb, then compare the resultingU with tc, etc., until te with tf. Then start again. In each runthrough count the number of inversions made; when this countis zero the process is finished. 'Remembering which relates towhich life tenant' is performed by setting up the numbers 1 to 6and inverting them when an inversion is made on the t's.

Supposed,. . .,v6contain 1,.. .,6; v7,...,v 12 contain ta,.. .,tb.vO is working space for inversions.

Page 38: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

13° S. BENJAMIN

3) n1 = 0 Counter of inversionsn2 = 0 Modifier

2) ->1, v(8+n2) > v(7 + n2) ]vO = v(7 + n2) Jump if right order, otherwisev(7 + n2) = v(8 + n2) reverse using vO as working spacet)(8 + n2) = vO J

vO = v(1+n2)v(l + n2) = v(2 + n2) R e v e r s e c o r r e s p o n d i n g p a i r o f 1 . . . Iv{2 + n2) = vOnl = n1 +1 Count the inversion

1) n2 = n2 +1 Next pair-> 2, n2 = 5 Loop unless 5 pairs completed-»• 3, n1 == 0 Repeat unless no inversionsEnd

Provided the above programme contains no errors, we have the t'sin ascending order in v7,... ,v12 and the corresponding identifyingnumbers 1, . . . ,6 in v\,... ,v6, where v1 relates to vl, etc. Thus vlcontains the number of the life tenant who dies first and v7 containsthe time to her death, etc. The programme was written to takeany number of life tenants up to ten, and the part which followedthrough the rules of the will was gathered into one subroutine.Hence by rewriting only this subroutine any similar problem canbe run on the same programme in future.

Once programming methods and computer techniques becomeeveryday knowledge in the profession we can look forward to anarticle in J.S.S. showing how to look at almost any reversionsproblem in a standard way, so that apart from reading in a fewdetails particular to the case in hand the same programme willcope. Thus, for example, it will be explained that children of lifetenants should be treated as dummy life tenants in a certain way;that different rates of interest should be applied to each life tenant,the above example being a special case of the general, etc. Analternative would be the development of a special autocode whichwould enable each problem to be programmed very quickly andeasily, such as the 'Montecode' developed for simulation work inthe iron and steel industry, where statements of the type 'SCAN'

can be made and where one can move automatically to the equiv-alent of the next death.

Notes

Page 39: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 131

With luck such an article may appear in J.S.S. within the nexttwo years, say within thirty years of the first actuarial interest incomputers. The article may even be written by someone who isinterested in reversions.

STOP-LOSS AND ALL THATOR

MURDER IN THE PENSION SCHEME

Most traditional actuarial work can be effected by commutationfunctions because the values required are essentially 'expected'values. The most that is usually required in the way of variationabout the expected is that the final value should be on the safe side;furthermore, it is usually, though not always, clear how to obtaina suitable margin.

In recent years a type of contract, namely group life assurancewith rebate of premium, has come into prominence, for whichtraditional actuarial methods give no adequate answer to the prob-lem of calculating a premium. The problem is essentially one of'variation' in mortality experience. A typical contract will chargea premium P for a one-year temporary assurance on a group oflives; at the end of the year a rebate is given if 0.9P > C whereC is the total claim. The amount of the rebate is .8(.9P.C).

It is easy to write down an equation for the premium; if thetrue expenses are (1 —g)P, the net premium gP must support theclaim and any rebate, i.e.

where p(C) is the probability distribution of the total claim C.The difficulty has all been swept into the expression p(C). Aglance at the recent paper by P. M. Madders in f .S.S. 16, 346, givesan idea of the ingenuity required to obtain a numerical solution.

The tradition of Continental actuaries has been somewhatdifferent, and they have been grappling with claim distributionsfor a long while. Their approach has been analytical, under theheading 'The Theory of Risk' and the main line of attack has

Page 40: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

I 3 2 S. BENJAMIN

been that of curve-fitting—with the usual difficulties of this ap-proach that a compromise must be found between curves which fitthe data and curves which are amenable to analytic manipulation.

The natural approach via computers would be quite differentand the following pages are devoted to using the simulation method(Monte Carlo) to obtain claim distributions and premiums forvarious types of contract, including

(a) group life with rebate,(b) 'stop-loss' reinsurance—where the reinsurer pays the

excess above a given amount when the total claim exceedsthis amount, and

(c) 'excess-of-loss' reinsurance—where the reinsurer pays theexcess above a given amount on each individual claim whichexceeds the given amount.

'Stop-loss' is an interesting form of insurance (or reinsurance).It is very new in the life field but considerable interest in it seemsto have arisen recently. It is suitable for pension schemes andnew life offices but the accepting market is very small and seeminglyhaphazard. There is also the possibility that the life offices willresist its introduction on the grounds that it might 'kill' the usualmethods of group assurance and reinsurance.

The problem of calculating stop-loss premiums is virtually thesame as that of calculating group-life premiums with rebate. Thelatter are quoted freely at the moment, but so far as I know thetariff rate has merely been picked out of the air at 10% above thenormal premium (without rebate).

Let us consider the basic problem. Given the age x and the sumassured S for each member of a group scheme, and a suitablemortality table, the expected claim for one year is

where St = sum assured for the ith member, qt = value of qx forthe ith member, N = number of members, i = 1,.. .,N.

Suppose we now choose a certain value A, e.g. twice the expectedclaim, and ask an insurer to pay only when the total claim exceedsthis value—known as the 'priority' or the 'deductible'. We now

Page 41: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 133need to know the way the total claim will fluctuate, i.e. we needthe distribution of total claim, and for this purpose the MonteCarlo technique is a 'natural'. All we have to do is to simulateone year's mortality experience a large number of times. Supposewe do 1000 simulations, obtaining 1000 examples of possible totalclaim, say Cv C2, . . . , C1000. By summing those values of C whichare greater than the given 'priority' A, and dividing by 1000, weobtain a close estimate of the pure premium required for a stop-loss insurance, i.e.

(To find the premium for a group life contract with rebate alittle further work is required.)

There are several methods of carrying out the simulation.

Method IThis is the straightforward method.Take each member i and read in his values of age xt and sum

assured St. Look up his mortality rate, say qt. Generate a randomfraction/. I f /< q we say that member has died and add his sumassured St into the claim total C, otherwise not. Then we pass onto the next member. When we have dealt with all N members wehave built up a total claim, say Cx. By repeating the whole process1000 times we obtain 1000 simulated claim-totals C1... C1000.

Clearly if/is uniformly distributed in the range (0, 1) then theprobability that f < q is q and we are 'killing off' the memberswith the required probabilities.

The programme could look as follows:

We require two data tapes:

(a) A table of qx; suppose this starts at age 11 and ends withthe marker L; it is read into v11 onwards.

(b) The members' data consisting of pairs of numbers x, S andterminated by any negative number, say —1. We assumethe end of the paper-tape has been joined to the beginningto form a continuous loop which will just run round andround.

Page 42: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

S. BENJAMIN134

We reserve boxes v201,.. .v1l200 for the totals of the 1000simulations; v201 will be used for the total claim from the firstrun through the scheme and so on. We use n2i to count the numberof simulations up to 1000 and also as a modifier to step appro-priately through v201,. . . ,v1200.

We put the age x in box n\ and hence we shall find qx in box vn\.

We put the sum assured S in vl.Notes

v0 = SQRT 2 \ Set opening value of randomvO = FRAC vO / fraction in vOSTOP To insert qx tape in tape-readervll = TAPE* Read qx tape into vll onwardsSTOP To insert members' data tapetil = 0 Counter for number of simulations

1) v(201 +n2) = 0 Clear box for total claim3) n\ = TAPE Read x

2, 0 > n1 Jump if age is negative, i.e. end ofdata

v1 = TAPE Otherwise read S

4) vO = vO X 10

4, 1000 > vO ~ ' n Generate a random fraction in v0)vO = SQRT vOvO = FRAC vO

3, vO > vn\ Jump back to read next member iff > qx, i.e. if member does notdie, otherwise

v(201 +n2) = v(201 +n2) + v1 Add 5 into claim total-> 3 Go back to read next member

2) n2 = n2 +1 We only reach this point after endof data; so step up n2, and

-> 1, n2 = 1000 Start all over againSTOP End( 0) Directive to start obeying

programme.

This programme contains 20 instructions written. Let us counthow many are obeyed if the scheme contains N members. Weneed concern outselves only with the major loops.

(a) Each random fraction requires at least 8 instructionsobeyed because the pair of instructions 4) and -4 areobeyed at least 3 times.

\ Set opening value of random/ fraction in v0To insert qx tape in tape-readerRead qx tape into f l l onwardsTo insert members' data tapeCounter for number of simulations

1) v(201+n2) = 03) n\ = TAPE

-> 2, 0 > n1

1 ) 1 = TAPE

4) v0 = v0 x 104, 1000 > v0

vO = SQRT vOvO = FRAC vO

3, vO > vn1

vO = SQRT 2

VO = FRAC VO

STOP

vll = TAPE*

STOP

n2 = 0

Clear box for total claim

Read xJump if age is negative, i.e. end of

dataOtherwise read S

Generate a random fraction in v0

Jump back to read next member iff > qx, i.e. if member does notdie, otherwise

Add <S into claim totalGo back to read next member

We only reach this point after endof data; so step up «2, and

Start all over againEndDirective to start obeyingprogramme.

v(20l+n2) = v(201+n2) + l->3

2) n2 = n2 + l

-> 1, n2= 1000STOP( 0)

Page 43: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 135

(b) Each member starts at 3) and apart from the few (say 5 per1000 on average) who die, they all continue until theconditional loop back at -> 3, vO > vnl. Say iV(4+a) =12N instructions obeyed.

(c) Each simulation starts at 1) and continues until -> 1,nl = 1000. Say 1000(3 +b) = 1000(3 + 127V) instructionsobeyed. Thus if N = 1000 members we have 12,003,000instructions obeyed.

(d) To this must be added reading time for 2000N numbers.

To digress for a moment; one of the most difficult things to dois to estimate how long a job will take to do on a computer.However, if the inner loop of the programme can be specified,even writing it down in autocode is a big step towards estimatingthe time required. Unfortunately, in many data processing jobs it isextremely difficult to decide what the inner loop of the programmewill contain until the job is at an advanced stage of specification.

In the case of our present example we have a scientific programmerather than a data-processing one, i.e. small input and output, andshort-written programme with tight loops obeyed a large numberof times.

Thus one could estimate the time to do our present examplefairly well from the above information. For any particular machineone would want to know the average instruction time, the timefor subroutines such as generating a pseudo-random fraction, andthe speed for reading data (including re-winds if on magnetic tape).

A rough guess at some timings at two extremes would be(N = 1000):

In Pegasus autocode on Pegasus—note that most autocodes canbe run on more than one machine; some autocodes can be run onthe machines of different manufacturers—the instructions areobeyed at about 20 per second making 170 hours together withpaper-tape reading time of say 30 hours. Say approximately200 hours.

On Atlas, operating one machine instruction per microsecond,perhaps approximately 2 minutes would be required, allowing forseveral machine instructions to each autocode instruction.

Page 44: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

136 S. BENJAMIN

This problem was set to the Students Society ProgrammingCourse. It was carried out in machine language on Pegasus withthe data on magnetic tape and took about 10 minutes. This figureis totally inconsistent with the above figures. It is in fact about200 times faster than it would be on a straight comparison but thiswas due to the use of a different method.

A factor of 200 represents in terms of cost a reduction from poundsto pence and in my opinion makes the difference between makingthe use of Monte Carlo methods for these problems prohibitivelycostly and making them extremely cheap. The nominal cost of½ second on Atlas to quote a group life premium would be swampedin the handling charge.

We turn to Method II.

Method II

(The method described here is an improved version of the oneused by the Students' Society Programming Course. It is in facta direct result of criticisms by the 'students'. Similarly, I wouldexpect in the future that if the new Advanced Study Groupbecomes the focus of actuarial research which it deserves, thenany project handed to it is likely to suffer considerable changefor the better by the time the 'students' hand back theanswers.)

The trouble with Method I is that most of the random fractionsgenerated—199 in 200 on average—are wasted on survivors. Byavoiding this waste Method II achieves its considerably higherspeed.

Suppose we had carried out 1000 simulations by Method I andlaid out the deaths as follows:

Simulation

Member

123

N

Total claim

1

St

c,

2

Ss

c2

3

S1

SN

C2

4

Sa

C4

500

SN

C100

501

S2

s3

C501

1000

S1

SN

C100

Page 45: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 137

Method I worked down the columns. In the above tableau, inthe first simulation member 1 survived, member 2 died, etc.; inthe second simulation member 1 survived.. .member TV died; andso on.

Suppose that instead of doing this we try to fill in the whole ofthe top row first, i.e. member 1, and then pass on to the next row,member 2, and so on. Consider the row for member 1 and let usgo straight for the interval between his successive 'deaths'. Inthe tableau, member 1 died in simulation year 3 and again insimulation year 1000.

Now the probability that member 1 dies in any simulation yearis qx since his age does not change from one simulation (year) toanother. Hence the probability that he first dies in simulationyear r is

and we note that

Thus if we generate a random fraction/ and sum the series

until we have

and

then we may take simulation year r as the year of first death ofmember 1. If r goes longer than 1000 then he does not die at allin the whole 1000 simulations.

Having found his first year of death, we can revive him and findthe interval until his next death in exactly the same way.

From the above we have that

as can be seen easily from first principles. Hence, havinggenerated f we need to solve

1-pr = f

Page 46: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

138 S. BENJAMIN

to find r. In general r will not be an exact integer and we need thenext higher integer.

We can simplify further by noting that if f is a random fractionuniformly distributed in the range (0, 1) so is 1 —f. So we maywrite more simply

Pr=for

We can tabulate the values of log px at the beginning of theprogramme, then to find r we need only to generate/, take its logand divide by the tabulated value of log px.

Successive values of r are added together until 1000 years arecovered; we then pass on to the next member.

The basic flow-chart for this programme is as follows:

Set C1t.. .C1000 = 0

Read a member's x, SSet simulation-year counter R = 0Generate fForm rAdd r to simulation-year counter R?R > 1000

Yes No

Add member's S to CB

A test for end of scheme data (e.g. age = — 1) should be insertedafter reading each member's data.

The programme would be:

Notes

\ Set opening value of random/ fraction in vO

To insert qx tape in tape-readerread qx tape into v11l onwards;n0 then equals the number of qx

Read in

to the next higher integer.

V0 = SQRT 2V0 = FRAC V0STOPV11 = TAPE*

«2 = 0

Page 47: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 139

Notes

5) v(ll+n2) = l -v( l l+n2) ]v(ll+n2) = LOGV(11+N2) [Replace the qx by log px using an2 = n2 +1 I short loop of instructions->5, nO > n2n2 = 0 j ln this programme v201-vl200

6) v(201 +n2) = 0 I must all be zeroized beforehandn2 = n2 + 1 [ t o build up the claim totals-> 6, n2 =# 1000 C 1 . . .C1000.

STOP To insert members' data tape

1) n2 = 0 Zeroize R for new membernl = TAPE Read x-> 2, 0 > n1 End of data tape if age is negativevl = TAPE Read S

4) vO = vO x 104, 1000 > vO I Generate a random fraction/

v0 = SQRT vO in vOvO = FKAC vO

v2 = LOGV0 Logfv2 = v2/vn1 Log f/log Px

v2 = INT V2 Integer partv2 = v2 +1 Next higher integer = rn3 = v2 n3 = r (see note below)n2 = n2 + n3 Add r to R-> 1, n2 > 1000 New member if we have over-shot

the 1000 simulation years,otherwise

v(200 + n2) = v(200+n2)+vl Add sum assured to CR total and4 generate a new f

2) STOP End( 0) Directive to start obeying

programme

(Note, n-boxes and v-boxes cannot be added together directly.)

The advantage of this method is that every random fractiongenerated is used directly to produce a useful death.

A string of 1000 sample values of total claim, in random order,is not a very useful thing to print out. If we wish to process themin any way we can do it by programme. Visually a histogram ismore useful. Some members of the Students' Society course tookan interval of 5 % of the expected claim and produced the following

Page 48: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

S. BENJAMIN140

distributions for an actual group life scheme, using A49/52 selectand A49/52 ult.

Amount ofclaim as apercentageof expected

claim

0-5-

10-15-20-25-30-35-40-45-50-55-60-65-70-75-80-85-90-95-

100-105-110-115-120-125-130-135-140-145-

Number of timestotal claim fell inthe interval when

the basis was

A49/52sel.16004

393221

84

594425252332863523245741363918234522202514

A49/52ult.203188

11237

251431503249544467554366444745225045222516

Amount ofclaim as apercentageof expected

| -Claim

150-155-160-165-170-175-180-185-190-195-200-205-210-215-220-225-230-235-240-245-250-255-260-265-270-275-280-285-290-295-300-

Number of timestotal claim fell inthe interval when

the basis was

A49/52sel.14311187

20109

156273431430000001001000

1000

A49/52ult.1416

5171075634210010000000000000000

1000

In general the distribution of total claim is not Normal—itdepends on the distribution of sums assured—and this is where theanalytical difficulties arise. The data used by the Students' Societywere, however, from a works scheme in which the sums assuredwere within a very narrow range and the above distributions maybe found to be near Normal.

Page 49: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 141

The following figures summarize one run of this experiment:

Number of members 1339Total sum assured £942,700

A 49/52 sel. A49/52 ult.

Expected claim Sq £2626.31,894,073

3.753£2569

£5269.63,800,302

7.536£5214

We can test the deviation of the mean claim from the expectedvalue by using

= S2q/1000,

whence A49/52 sel. A49/52ult.

-1 .3 -0.9

Neither is significant at the 5 % level and the simulations canbe accepted as sufficiently good for further use.

The calculation of a premium with rebate

To find a group life assurance premium, with rebate, on theformula stated at the beginning of this section, viz.

we need to solve the equation given there in analytical terms. Interms of our simulated claim totals C I . . .C 1 0 0 0 the equationbecomes

i.e. the premium over 1000 simulations must support the claimsand the rebates.

The formula we shall discuss puts g = 1 and is in general

IO ASS I7

= Sq ,

var

S.D.

S2qExpected no. of deaths qMean claim from simulations

Page 50: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

142 S. BENJAMIN

The natural computer approach to this is by successive ap-proximation. (Iterative methods are obviously well-suited tocomputers.) The method used first calculated the value of

for the two extremes P1 = 0, and P2 = maximum value of Ci.We have/(0) < 0 andf(max Ci) > 0 by inspection. We then usesuccessive binary cutting of the interval until f(P) = 0. Thus thenext trial value of P is

P3 = ½(0+max. Ci).

If/(P3) < 0 substitute P3 for P1 and take P4 = ½(P3+P2).If/(P3) > 0 substitute P3 for P2 and take P4 = ½(P1+P3).Iff(P3) = 0 this is the solution.Etc.

We have reached the stage where we can say that the 'student'should be able to programme this for himself. (It is worth in-serting two tests for the end of the process;

orwhere e' and e" are suitably chosen small constants. Also theprogramme should be written to read in different values of k anda.)

Some numerical results

If we put k = 1 so that some proportion, a, of the full differencebetween the premium and the claim is returned we can see thatif a = 0 then we have a straight contract for which we have

P = C from the sample, (i)or Sq from the population. (ii)If a = 100% then

P max. Ci from the sample, (iii)

or S from the population (iv)

will satisfy the contract.

P =

P

Page 51: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 143(i) Differs from (ii) because of random fluctuation. This is also

true for (iii) and (iv), but from a random sample of only 1000values we find max Ci is considerably less than S. Otherwise,if a = 100%, P is independent of the mortality. In the schemeused above we had

S = £942,700,

max Ci = £7,500 on A49/52 select

£11,800 on A49/52ult.

(We return to this point later.)Now it is intuitively clear that the greater a becomes, i.e. the

greater the proportion returned to the scheme, the greater theelement of profit-sharing and the less relevant is the mortality.Some experiments were carried out in order to find at what sizeof a the premium stabilizes. Values of P for different k and a werecalculated from the simulations carried out on the two basesA49/52 select and A49/52 ult., the former being convenientlyabout one half of the latter. The results were as follows:

Premium for given group life scheme where rebate is of form

α(kP-C)when kP > C.

%k

0

20

40

60

80

100

0

25695214

25695214

25695214

2569

5214

2569

5214

2569

5214

20

25695214

25715215

2579

5220

2597

5238

2631

5286

2688

5388

40

25695214

2572

5216

2589

5226

2627

5263

2702

5367

2844

5614

60

2569

5214

2574

5216

2600

5232

2659

5289

2787

5459

3071

5939

80

2569

5214

2576

5217

2611

5238

2694

5316

2889

5565

3463

6496

100

2569

5214

2577

5218

2622

5244

2731

5344

3019

5690

7500

11800

Upper figure is premium on A 49/52 select.Lower figure is premium on A49/52 ultimate.

1 0 - 2

Page 52: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

144 S. BENJAMIN

For k = 100% the range of a was further subdivided to give

P

8085909596979899100

A49/52 sel.

3463

3629

3862

42424364

4514

4709

5037

7500

A49/52 ult.

6496

6725

7052

7626

7806

8033

8344

8832

11800

These figures seem to demonstrate that the premium to becharged on a rebate formula is virtually as sensitive to the mortalitybasis as is a straight temporary assurance premium until we reachvalues of k and α of the order of 99.9%. In view of this perhapsthe phrase 'profit-sharing' which is often applied to these contractsis inappropriate.

Calculation of a stop-loss premium

In a stop-loss insurance a certain figure, known as the 'priority'or 'deductible' is named; if the total death claim for the yearexceeds this amount the insurer pays the excess.

The simplest way to find the premium for any value of the'priority' is to sort the simulated claim totals into ascending order.Let us call the result C1... C1 0 0 0.

Suppose as a typical example the 'priority' is to be set at twicethe expected claim. By inspection of the string of sorted valuessuppose we find that twice the expected claim lies between C8 7 5

and C8 7 6 (a typical result). Then the pure stop-loss premium beforeloadings is

(Ci - 2 x expected claim)/l000

Ci -125 x 2 x expected claim

Hence the summation column is worth tabulating—by

programme of course.

1000.

Page 53: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 145If the 'priority' is set equal to a particular value of C, say Cr,

then the premium becomes

[C1000+C999+ . . . +Cr-(1000-r+l)Cr]/1000

= [C1000 + C999+ • • • +Cr+1-(1000-r)Cr]/1000

Hence the summation column is worth

tabulating since it gives the premium corresponding to any'priority' immediately.

Sorting

The above paragraph requires us to sort 1000 numbers intoascending order, and clearly the method of inverting pairs whichwas described earlier become unwieldy.

Several methods of sorting on computers have been developed,all of them extremely cunning. One method in common use forsorting data both on magnetic tape and internally in the store isa 'string-merging' process, the principle of which can best beindicated by an example:

Suppose the numbers are first divided into two, approximatelyequal, parts A and B:

AB

71

82

69

1011

3

4

512

We set up two other areas C and D to receive them, and thenumbers are read successively from A and B into C or D accordingto certain rules.

First, we define a string as a group of consecutive numberswhich are in ascending order. We may mark off the strings in Aand B as follows:

AB

71

82

69

1011

II 34

512

Thus A contains three strings A1, A2, A3, and B contains twostrings Bl, B2. We merge Al with Bl and write the result toarea C thus:

Take the first member of A and the first of B, i.e. 7 and 1.Since 1 is the smaller, write it to area C and bring up the next

Page 54: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

146 S. BENJAMIN

member of B, viz. 2. Compare 7 with 2. Since 2 is the smallerwrite it to C and bring up 9. Compare 7 with 9. Now 7 is thesmaller; write it to C and bring up the next member of A, viz. 8.Since 8 is smaller than 9 write 8 to C. The first string of A isfinished so write the rest of B viz. 9 and 11 to C. Now deal withthe second string of A and the second of B similarly but writethe results to area D; and so on. The final result will be:

cD

14

26

710

812 |

9 11 3 5

We now pass back to areas A and B in the same way and con-tinue the passes until we have only one string.

Since the length of the strings roughly doubles at each pass theprocess is fairly efficient.

Fortunately one can reasonably expect any machine to be sup-plied with standard sorting subroutines as part of its 'software'(as opposed to 'hardware').

Calculation of excess-of-loss premiums

An excess-of-loss insurance is similar to a stop-loss contractexcept that the 'priority' is applied to each claim individually.There is probably a mnemonic for remembering which is whichbut I do not know one, and I find the only solution is to write itdown on a piece of paper at the beginning of any discussion.

In the simulation programme it is now necessary to set aside twosets of 1000 locations each in which to sum the claims. Supposethe priority is set at £1500. Every time a member dies his sumassured must be tested. If it is greater than £1500 the excessmust be carried to the appropriate simulation year in the secondset. The premium for the excess-of-loss contract is then the meanof the 1000 values in the second set.

I understand that the real experts then apply a stop-loss to theexcess-of-loss total, but they have not invented a special name forthis yet.

Probabilities of ruin

If we wish to investigate the probability of very high values oftotal claim—and some people do—then even Method II becomes

Page 55: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 147too lengthy. Thus if we wish to find the level of total claim whichwould be exceeded with a probability of only 1:1000 then 1000simulations would supply one example (the largest claim) onwhich to base an estimate; 100,000 simulations would be requiredin order to base an estimate on a sample of 100 values. With ' ruin'probabilities of the order of 1:1,000,000 even Atlas would becomeexpensive.

The following method appears to work but the only supportI can give for its theoretical validity is that three persons whoseopinions I respect have said that they cannot see anythingobviously wrong with it. Part of my suspicion arises from thefact that it has a peculiar feature which makes it too good to betrue.

Method III

One simulation is carried out as follows:

Let qi be the mortality rate for (the age of) member i. Let uskill off all the members of the scheme one after another, withoutrevival, and take a note of the total claim at each stage. Let 2} bethe total after the jth death. The process of killing must select eachdeath with a probability equal to the probability that out of thesurvivors at that stage that member will die, i.e.

qi/ qi,where the denominator is summed only over the survivors.

Thus, if there are N members of the scheme (i = 1 . . . N) inany order, form the summation column

Q1 = q1,

Q2 = q1 + q2,

QN = q1 + q 2 + . . . + q N .

Generate a pseudo-random fraction f, uniformly distributed inthe interval (0, 1). Form fQN and search down the Q column until

<Qi,

Qo = 0,

fQNQi-1

Page 56: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

148 S. BENJAMIN

and take the ith member as the one to die. His sum assured Si isthen copied away to T1 and represents the total claim after onedeath in the first simulation.

In order to prevent killing him again in this simulation we mayset his sum assured in the list of original data, negative.

Now adjust the Q column to omit qi and repeat the process.Form a newf. Form fQN-1. Search down the column until

Qi-1 fQN-1 < Qi

and take numberj as the next death. His sum assured Si is added tothe contents of T1 and copied in T2 and we have the following totals :

total claim after 0 deaths = 0 in box T0,

total claim after 1 death = Si in box T1,

total claim after 2 deaths = Si + Sj in box T2.

Now Sj in the original data must be set negative as a markerthat member j is also dead.

The process can be carried on until everyone is dead. At eachstage the sum assured for the dying member has to be found bycounting down the data omitting those members whose sumassured is already negative. We end up with an increasing sequenceof totals

where To = 0 and TN = Si because everyone is dead.If we carry out this complete simulation say 100 times we can

consider the results tabulated as follows:

Total claim after r deathsr

Simulation

12

100

0

TO(1)

To(100)

1

T1(1)

TI(2)

T1(100)

... r

. . . Tr(1)

... Tr(2)

Tr(100)

... N

... TN(1)

... TN(2)

... TN(100)

The entries in the first column will all be zero and the entries inthe last column will all be equal to the total sum assured Si.

To,T1, T2, . . . , TN,

Page 57: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 149Now consider a particular interval. For a scheme of 1000 lives

with expected claim of say £5000 we might be interested in theshort interval £15,000-£15,499. The probability that the totalclaim lies in this interval may be expressed as

r

probability claim liesin the interval, giventhat there are r deaths

probability thereare r deaths

Taking the second term first, using the Poisson distribution wemay take this as

e-mmr\r!

where m = the expected number of deaths.An estimate of the first term may be found from the tableau of

our simulation results. If we look down the column headed'r deaths' and count the number of times, nr, out of 100, that thevalue of Tr lies in the given interval then nr/100 is an estimate of theprobability that, given r deaths, the total claim lies in the giveninterval. Doing this for all columns we can form

(nr/100)(e-mmr/r!)

quite simply to obtain the required probability.Similarly, if required, the whole range of total claim from zero

to total sum assured can be covered by suitable intervals.

Method III in practice

As described above method III sounds very lengthy, and is.Fortunately in practice there is a saving feature. Consider a schemeof say 10,000 lives, in which one might expect about 50 deaths.To determine orders of magnitude we may use numbers of deathsrather than amount of claim. With an expected number of deathsequal to 50, the standard deviation of the number of deaths isabout 7. Hence we are very unlikely to be interested in practicein claims involving more than 90 to 100 deaths, i.e. 6 to 7 standarddeviations above the mean. Hence it is unnecessary to carry thesimulations beyond the first 100 or so deaths—a stopping rulebased on the total claim to date can be built into the programme.

Page 58: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

150 S. BENJAMIN

The first implication of this simplification is that the amountof storage required is cut considerably. The number of boxesapparently required at first was 10,000 for the basic data of sumsassured, plus 100 simulations x 10,001 for the various values of T,i.e. over 1,000,000. In practice 10,000+100x100, i.e. 20,000boxes only are required. Internal storage for 1,000,000 numbersis very rare as yet; machines with storage for 20,000 numbers arebecoming more common these days.

The second implication is that if in any one simulation we aregoing to kill only 1 % of the members, it is unnecessary to gothrough the long routine of adjusting the Q column at each death.If we leave the Q column unchanged we shall from time to timetry to kill a member twice, but inspection of his data will showhis sum assured set negative and we can merely ignore this particulardeath. The number of times this will happen will be very smallindeed. Clearly this also simplifies and speeds up the processingvery considerably.

In practice the data are usually presented in age order, or canbe sorted into this order, and it is unnecessary to carry a fullcolumn of Q. If the youngest age is a and the oldest b and thenumber of members at age x is Nx then two short columns

are all that is required.A search down the R column comparing with fRb establishe

the age group; e.g.Rx < fRb Rx+1

establishes age x; then

i = INT[(/Rb-Rx/qx] + l

establishes the ith member of that age group, i.e. the (Mx + i)thmember of the scheme, as the member to die.

Ma = Na

Ma+l = Na + Na+1

Mb = N a + N a + 1 + . . . + N b Rb = Naqa + Na+1qa+1 +

+ Nbqb

Ra+1 = N a q a + N a + 1 q a + 1

Ra = Naqa

Page 59: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 151

This method was programmed and tried out on the schemeused in our earlier numerical examples. We found the probabilitythat the total claim would lie between five and six times theexpected claim i.e. £12,845-£15,414 on A49/52 select and£26,085-£31,302 on A 49/52 ultimate. The results were .300 x 10-7

for the former and .222 x l0- 1 3 for the latter.Method II would presumably have required about 108 and 1014

simulations respectively to throw up examples of such extremeclaims. (As a guide 1014 microseconds = 31/4 years approximately.)

Peculiarity of Method HI

In Method III the major part of the work is carried out by thetime we have found the values of nr, and all that remains in orderto calculate the final expression is to form the Poisson probabilitiese-m, e-m, e-mm2/2!, . . . and carry out a few multiplications andadditions. But until that final stage nothing we did involved usingthe absolute values of the mortality rates—only their relativevalues to each other, i.e. using mortality rates equal to kqx wherek is a constant for all ages would have produced the same result.It is only at the stage of using m = expected number of deaths

that we use the absolute values of qx.

Hence if we wish to find the claim distribution, with specialemphasis on its awkward top tail, on several mortality bases kqx

for different values of k, Method III produces the extra resultsvery quickly.

It is not the purpose of these notes to discuss the statisticaldecision problem of allowing for uncertainty in the mortality basisto be used in the premium quotation for a given scheme, but inany calculation involving alternative hypotheses, Method IIIshould be extremely useful.

Page 60: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

S. BENJAMIN

EXAMINATION PAPER

May 1984, Part 13, Paper 7

152

1. In what circumstances would it be appropriate to carry outa Monte Carlo simulation of the mortality experience of a groupof lives, printing out the names of the deaths?

2. How would you carry out an experiment to determinewhether the probability model inherent in the usual life-tableadequately represents the year-to-year fluctuations in the mortalityexperience of a group of lives?

3. State the data you would require from your office's dataprocessing installation in order to relate your office's expenses tothe insurance sector of the National Economic Model.

4. It is required to smooth a set of crude mortality rates qx bymaximizing the expression

(where E = Ex = given exposed to risk at age x and 0 = 0 x =given number of deaths at age x) subject to the constraints

(i)(ii)(iii)

Explain how you would amend one of the standard quadraticprogramming methods (P. Wegner, J.S.S. 16, 468) to do this.

5. In the Preface to the a(55) tables certain adjustments to therates for future years were given. Discuss the results of theinvestigation by the Students Society's Computer Group in 1963when sequential analysis (Johnson & Moore, J.S.S, 14, 84) wasused to test the suitability of the adjustments. What was the resultof the similar investigation in 1966 on the a(65) table?

6. Given only the totals of sums assured by year of entry andthe totals by year of maturity for non-profit endowment assurances,how would you use a standard 'Transportation' programme toobtain absolute upper and lower bounds to the net liability?

7. If you found yourself in an under-developed country wherethe Standard International Actuarial Autocode was not available

Page 61: COMPUTERS AND ACTUARIAL SCIENCE S. BENJAMIN JSS 17 (2

COMPUTERS AND ACTUARIAL SCIENCE 153on the local computers, what special matrices would you store inorder to be able to use a typical matrix programming scheme forthose valuation calculations which still require the use of com-mutation functions?

8. Explain how you would use the net premium method ofvaluation in order to:

(i) project the future income from your investments,(ii) set your maximum retention on any one life,(iii) estimate the return on next year's agency selling drive,(iv) determine your maximum holding in equities,(v) determine the rate of bonus to declare,

by carrying out the calculations on dozens of different bases beforebreakfast on 1 January.