Four BASIC programs for life contingencies

Home Forums General Actuarial Four BASIC programs for life contingencies

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #6964
    Richard Purvey
    Participant

    BASIC Programs For Four Of The Standard Algorithmic Calculations Currently Included In The Actuarial Life Contingencies Syllabus

     

    In each case, make the first line of the program:

     

    10 DEF FNS(U)=whatever the survival function, S(U), is.

     

    For example, for a Makeham with A equal to 0.00022, B equal to 2.7*10^(-6) and c equal to 1.124, make the first line of the program:

     

    10 DEF FNS(U)=EXP(-0.00022*U-2.7*10^(-6)*(1.124^U-1)/LN(1.124))

     

    And then;

     

    If you want the program to calculate an n-year temporary curtate life expectancy for (x) when executed then add on the following:

     

    20 INPUT x,n

     

    30 ANSWER=0

     

    40 FOR r=1 TO n

     

    50 ANSWER=ANSWER+FNS(x+r)

     

    60 NEXT r

     

    70 ANSWER=ANSWER/FNS(x)

     

    80 PRINT ANSWER

     

    90 END

     

    Or if you want the program to calculate the actuarial present value of an n-year temporary immediate life annuity, with a discount factor of v, of 1 per year payable m times per year for (x) (m may be equal to 1) when executed then add on the following:

     

    20 INPUT x,n,m,v

     

    30 ANSWER=0

     

    40 FOR r=1 TO m*n

     

    50 ANSWER=ANSWER+v^(r/m)*FNS(x+r/m)

     

    60 NEXT r

     

    70 ANSWER=ANSWER/(m*FNS(x))

     

    80 PRINT ANSWER

     

    90 END

     

    Or if you want the program to calculate the actuarial present value of an n-year temporary life annuity due, with a discount factor of v, of 1 per year payable m times per year for (x) (m may be equal to 1) when executed then add on the following:

     

    20 INPUT x,n,m,v

     

    30 ANSWER=0

     

    40 FOR r=0 TO m*n-1

     

    50 ANSWER=ANSWER+v^(r/m)*FNS(x+r/m)

     

    60 NEXT r

     

    70 ANSWER=ANSWER/(m*FNS(x))

     

    80 PRINT ANSWER

     

    90 END

     

    Or if you want the program to calculate the actuarial present value of a death benefit, with a discount factor of v, of 1 payable at the end of the 1/m year of death for (x) (m may be equal to 1), provided this occurs within n years, when executed then add on the following:

     

    20 INPUT x,n,m,v

     

    30 ANSWER=0

     

    40 FOR r=0 TO m*n-1

     

    50 ANSWER=ANSWER+v^(r/m)*FNS(x+r/m)

     

    60 NEXT r

     

    70 ANSWER=ANSWER/(m*FNS(x))

     

    80 ANSWER=1-v^n*FNS(x+n)/FNS(x)-m*(1-v^(1/m))*ANSWER

     

    90 PRINT ANSWER

     

    100 END

     

     

    I have written the above programs in BBC BASIC which is very similar to the more commonly used VB.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.