Showing posts with label actuarial science. Show all posts
Showing posts with label actuarial science. Show all posts

Saturday, December 3, 2022

HP 15C and TI-84 Plus CE: Weibull Distribution Parameter Calculation

HP 15C and TI-84 Plus CE:  Weibull Distribution Parameter Calculation



Introduction


The Weibull probability density distribution function is:


f(x) = (b / Θ) * (x / Θ)^(b-1) * exp(-(x / Θ)^b)


with the lower tail cumulative distribution of (-∞ to x):


Area = 1 - exp(-(x / Θ)^b)


The area function tells us what is the probability a device lasts no more than x time units.  


Area = 1 - Survival


The survival function is the probability a device lasts more than x time units.


Survival = exp(-(x / Θ)^b)


Generally, the higher Θ is, the flatter the Weibull Distribution curve.  


In today's blog, we are estimating the parameters b and Θ given the number of data points, N, and data points (time periods to failure) x_i.   For the HP 15C program, which is modeled after the HP 55 program (see source below).   



The Process


Each x_i is sorted in ascending order.  Then transform the following data:


x' = ln x


α = (K - 0.3) ÷ (N + 0.4),  K = 1, 2, 3, ... , N


y' = ln( ln( 1 ÷ (1 - α)))


Enter each point (x', y'), and perform a linear regression analysis.


Then:  


b = slope


Θ = e^-(intercept ÷ slope)


 


HP 15C Program:  Weibull Distribution - Parameter Determination


Line #;  Key;  Code


001;  LBL A; 42, 21, 11

002;  1;  1

003;  STO 0;  44, 0

004;  CLΣ;  43, 32

005;  R/S;  31

006;  STO 1;  44, 1

007;  LBL 9;  42, 21, 9

008;  R/S;   31

009;  LN;  43, 12

010;  RCL 0;  45, 0

011;  . ;  48

012;  3 ;  3

013;  - ;  30

014; RCL 1;  45, 1

015; .  ;  48

016; 4 ;  4

017; +  ; 40

018; ÷ ; 10

019; 1 ;  1

020;  STO+ 0;  44, 40, 0

021;  x<>y  ; 34

022;  - ; 30

023;  1/x ;  15

024;  LN ; 43, 12

025;  LN ; 43, 12

026;  x<>y ; 34

027;  Σ+ ; 49

028;  GTO 9; 22, 9

029;  LBL B; 42, 21, 12

030;  L.R.;  42, 49

031;  x<>y ; 34

032;  R/S ; 31

033;  ÷ ; 10

034;  CHS;  16

035;  e^x;  12

036;  RTN;  43, 32


1.  Execute label A.   

2.  Enter N, the number of data points, then press the R/S key.

3.  Enter each x_i in ascending order, press R/S key in between each keys.  

4.  Execute label B.   The b parameter is displayed.  

5.  Press R/S.  The Θ parameter is displayed.



TI-84 Plus CE Program: WBFIT  


Weibull Distribution - Parameter Determination


"EWS 2022-10-09"

ClrHome

Disp "WEIBULL DIST.","FIT CALCULATION"

Input "DATA LIST: ",L1

SortA(L1)

dim(L1)→N

ln(L1)→L1

N→dim(L2)

For(K,1,N)

(K-0.3)/(N+0.4)→A

ln(ln(1/(1-A)))→L2(K)

End

LinReg(a+bx) L1,L2

b→B

e^(­(a/b))→θ

ClrHome

Disp "1-e^(­(X/B)^θ)"

Disp "B:",B,"θ:",θ


The x_i data are sorted in the WBIT program.  



Examples


Example 1:

Hours to failure:

{ 11000, 11056, 11379, 11821, 11956, 12403, 12526, 13000, 13380, 13663 }

N = 10


b ≈ 14.01123

Θ ≈ 12649.59071


Example 2:

Days to failure:

{ 1760, 1799, 1882, 1931, 1996, 2004, 2150 }

N = 7


b ≈ 15.22473

Θ ≈ 1993.22461


Sources:


HP55 Statistics Programs  Hewlett Packard Company.  Cupertino, CA.  1975


Ma, Dan.  "The Weibull distribution"  Topics in Actuarial Modeling.  September 28, 2016.   https://actuarialmodelingtopics.wordpress.com/2016/09/28/the-weibull-distribution/  Last Retrieved September 20, 2022.  



Eddie


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


Sunday, November 13, 2022

HP 15C: Weibull Distribution Calculations

HP 15C:  Weibull Distribution Calculations


Introduction


The Weibull probability density distribution function is:


f(x) = (b / Θ) * (x / Θ)^(b-1) * exp(-(x / Θ)^b)


with the lower tail cumulative distribution of (-∞ to x):


Area = 1 - exp(-(x / Θ)^b)


The area function tells us what is the probability a device lasts no more than x time units.  


Area = 1 - Survival


The survival function is the probability a device lasts more than x time units.


Survival = exp(-(x / Θ)^b)


Generally, the higher Θ is, the flatter the Weibull Distribution curve.  


What follows are four calculations regarding the Weibull Distribution.  In the following programs, store the following values first prior to running the programs:


R0 = x

R1 = b

R2 = Θ


Use whatever labels you like.  


HP 15C Program:  Lower Tail Probability - Weibull Distribution


CDF = 1 - exp(-(x/Θ)^b)


Keys:


LBL B

1

RCL 0

RCL÷ 2

RCL 1

y^x

CHS

e^x

-

RTN


Key Codes:


42, 21,12

1

45, 0

45, 10, 2

45, 1

14

16

12

30

43, 32


Example:  

b = 1.96, Θ = 420

x = 300, result:  0.4038

x = 400, result:  0.5970

x = 500, result:  0.7552


HP 15C Program:  Failure Rate - Weibull Distribution


FR = b/Θ * (x/Θ)^(b-1) 


Keys:


LBL C

RCL 1

RCL÷ 2

RCL 0

RCL÷ 2

RCL 1

1

-

y^x

*

RTN


Key Codes:


42, 21, 13

45, 0

45, 10, 2

45, 0

45, 10, 2

45, 1

1

30

14

20

43, 32


Example:  

b = 1.96, Θ = 420

x = 300, result:  0.0034

x = 400, result:  0.0045

x = 500, result:  0.0055


HP 15C Program:  Mean of a Weibull Distribution


µ = (1/b)! * Θ


Keys:


LBL D

RCL 1

1/x

x!

RCL× 2

RTN


Key Codes:


42, 21, 14

45, 1

15

42, 0

45, 20, 2

43, 32


Example:  

b = 1.96, Θ = 420

Result:  373.3720


HP 15C Program:  Standard Deviation of a Weibull Distribution


σ = Θ * √((2/b)! - (1/b)!^2)


Keys:


LBL E

2

RCL 1

÷

x!

RCL 1

1/x

x!

x^2

-

√

RCL× 2

RTN


Key Codes:


42, 21, 15

2

45, 1

10

42, 0

45, 1

15

42, 0

43, 11

30

11

45, 20, 2

43, 32


Example:

b = 1.96, Θ = 420

Result:  198.2208


Sources:


HP55 Statistics Programs  Hewlett Packard Company.  Cupertino, CA.  1975


Ma, Dan.  "The Weibull distribution"  Topics in Actuarial Modeling.  September 28, 2016.   https://actuarialmodelingtopics.wordpress.com/2016/09/28/the-weibull-distribution/  Last Retrieved September 20, 2022.  



Eddie


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


Saturday, January 23, 2021

Annuity Due in Terms of Ordinary Annuity

Annuity Due in Terms of Ordinary Annuity


Annuity:  Ordinary vs. Due


The distinction is determined when the first payment is made:


Ordinary Annuity:   the first payment is made at the end of the first period, with no payment made at the beginning (period 0) of the annuity. 


Annuity Due:  the first payment is made at the very beginning of the annuity, with no payment made at the end of the annuity.  


For today's exercise, assume all payments in annuity are all equal.  To simplify, I am going to set payments to 1 monetary unit (Dollars, Euros, Lira, Yen, etc).


Present Value



The present value of an annuity is today's value of the annuity, with future payments and cash flows are discounted back to today using the periodic interest rate.  On financial calculators, the present value is symbolized by the PV key.  


Let i be the interest rate of the annuity, in decimal format.  

Example, for 5% periodic rate, i=0.05.


Let v = 1/(1 + i).   


Present Value of an Ordinary Annuity


Given the payment of 1 monetary unit, an annuity of n periods, equally spaced out, and interest rate i, the present value of this ordinary annuity is the sum:


PVAF = v + v^2 + v^3 + ... + v^(n-1) + v^n = Σ(v^x for x=1 to n)


The above is known as the present value annuity factor, or PVAF.  


A closed formula for PVAF is:


PVAF = (1 - (1 + i)^-n) / i


Present Value of an Annuity Due


Likewise, the present value of the annuity due is the sum:


PVAFD = 1 + v + v^2 + v^3 + ... + v^(n-1) = Σ(v^x for x=0 to n-1)


A closed formula for PVAFD is:


PVAFD = (1 - (1 + i)^-n) / (1 - 1/(1 + i))


We can express PVAFD in terms of PVAF by:


PVAFD = 1 + v + v^2 + v^3 + ... + v^(n-1)

PVAFD + v^n = 1 + v + v^2 + v^3 + ... + v^(n-1) + v^n

PAVFD + v^n = 1 + PVAF

PAVFD = 1 + PVAF - v^n


PAVFD = 1 + (1 - (1 + i)^-n) / i - (1 + i)^-n


Example:  i = 0.04, n = 36


PAVFD = 1 + (1 - 1.04^-36) / 0.04 - 1.04^-36 ≈ 19.6646


This is the same as setting up TVM (time value of money) keys on most financial calculators or any calculator with a TVM solver as:

n = 36, I = 4, PMT = -1, FV = 0, (if needed, P/Y = 1),  BEGIN mode

Solve for PV:  19.6646...


Future Value



The future value of an annuity is the final value of the annuity, including the accumulated interest of payments and cash flows from the date the payment to the end of the annuity.  On financial calculators, the future value is symbolized by the FV key.  


Let w = 1 + i


Future Value of an Ordinary Annuity


Given the payment of 1 monetary unit, an annuity of n periods, equally spaced out, and interest rate i, the future value of this ordinary annuity is the sum:


FVAF = 1 + w + ... + w^(n-3) + w^(n-2) + w^(n-1) = Σ(w^x for x=0 to n-1)


The above is known as the future value annuity factor, or FVAR.  

A closed formula for FVAF is:


FVAF = ( (1 + i)^n - 1 ) / i


Future Value of an Annuity Due


Likewise, the future value of the annuity due is the sum:


FVAFD = w + ... + w^(n-3) + w^(n-2) + w^(n-1) + w^n = Σ(w^x for x=1 to n)


A closed formula for FVAFD is:


FVAFD = (1 + i) * ( (1 + i)^n - 1 ) / i 


We can express FVAFD in terms of FVAF by:


FAVFD = w + ... + w^(n-3) + w^(n-2) + w^(n-1) + w^n 

1 + FAVFD = 1 + w + ... + w^(n-3) + w^(n-2) + w^(n-1) + w^n 

1 + FAVFD = FAVD + w^n

FAVFD = FAVD + w^n - 1


FAVFD = ( (1 + i)^n - 1 ) / i + (1 + i)^n - 1


Example:  i = 0.04, n = 36


FAVFD = (1.04^36 - 1) / 0.04 + 1.04^36 - 1 ≈ 80.7022


Using the TVM keys or solver:

n = 36, I = 4, PMT = -1, PV = 0, (if needed, P/Y = 1),  BEGIN mode

Solve for FV:  80.7022...


On tomorrow's blog, January 24, I will cover two actuarial problems. 


Source:


Finan, Marcel B.  A Basic Course in the Theory of Interest and Derivatives Markets:  A Preparation for the Actuarial Exam FM/2   Arkansas Tech University, 2017.  



Eddie


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


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

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