Upload
duongminh
View
231
Download
3
Embed Size (px)
Citation preview
68
Beta distributions of First and Second kind
In this chapter we consider the two kinds of Beta distributions.
5.1. Beta Distribution of First Kind
The Beta distribution of first kind is defined by the following pdf
, 0<x<1
= 0, otherwise
Where a> 0 and b>0 both are shape parameters.
The mean and variance of this distribution are
E (X) = ; V(X) =
The beta distribution has been applied to model the behavior of random variables limited to
intervals of finite length in a wide variety of disciplines. In population genetics it has been
employed for a statistical description of the allele frequencies in the components of a sub-
divided population. It has been utilized in PERT, critical path method (CPM) and other project
management / control systems to describe the statistical distributions of the time to completion
and the cost of a task. In Bayesian inference, the beta distribution is the conjugate prior
probability distribution for the Bernoulli, binomial and geometric distributions
69
5.2. Parameter Estimation
In this chapter we are interested in estimating the parameters of the Beta distribution of first
kind from which the sample comes. Here we present the method of moments as the MLE does
not give a neater expression and the Local frequency ratio method of estimation.
5.2.1 Method of moments
The r th moment about origin is
dx
dx
By using Beta integral, we can simplify as
Replacing Beta by Gamma, we get
Putting r = 1,2
……..(5.1) ( using )
70
………….(5.2)
Equating the sample moments with the corresponding theoretical moments, we get
. and =
Solving these equations, we get the following estimators:
5.2.2 Frequency Ratio Method of Estimation
As explained in the Chapter 3, we now estimate the parameters by considering local frequency
ratio method.
Putting x = x1, x2 and x3 the pdf of Beta distribution of first kind, we get f1, f2 and f3
, 0<x<1
71
In this case we compute theoretically three frequencies as we have two parameters to be
estimated, The Ratio of frequencies is
=
=
Taking logarithms on both sides,
here
Similarly,
=
Taking logarithms on both sides,
here
72
Solving (5.3) and (5.4), we get estimates of a and b as
and
Illustration:
For Estimating parameters, we generate a sample of size 1000 from a Beta (a=2, b=3)
distribution using MATLAB function. For the generated data a frequency distribution is
constructed.
For example, using x= betarnd (2, 3, 1000) the following distribution is obtained.
x
(Mid-value) 0.0484 0.1452 0.2419 0.3387 0.4355 0.5322 0.6290 0.7258 0.8225 0.9193
f 45 116 151 157 168 155 107 63 24 14
Using these frequencies and mid values in the above formulae, we get estimates of a and b as
The above procedure is repeated for 50 samples. The mean, Standard Deviation , of
these 50estimates were computed. The estimated bias was calculated as the mean minus the true
value of the parameter. The Mean Squared Error (MSE) was calculated as the bias squared plus
the variance .
73
Table 5.1
From the above table, we notice that the actual values of (a, b) and the mean estimated values of
(a, b) are almost same. Therefore, it can be taken as a good estimator. Similar procedure is
followed for different sample sizes and different values of (a, b).The results of both the
estimation procedures are listed in the tables 5.2 to 5.6 along with the histograms figures 5.1 to
5.6. The MATLAB programs are listed in the Appendix.
(a=2,b=3)
ns=50
Method of moments Frequency Ratio method
a b a b
Mean 2.0216
3.0248
2.0388
3.0659
Sd 0.1081 0.1562
1.1239
2.2443
0.2720 0.7451 0.3788
0.5050
2.1383 2.8472 2.5355 2.7952
Bias 0.0216 0.0248 0.0388 0.0659
MSE 0.0005 0.0006 0.0028 0.0094
74
5.3 Comparison of Method of moments and Frequency Ratio Method for
Different Sample sizes and Parameters:
Table 5.2: Simulation Statistics for Beta (1, 5)
Table 5.3: Simulation Statistics for Beta (3, 1)
(a=1,b=5)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a b a b
Mean 0.9939 4.9999 0.9981 5.0960 1.0066 5.0418 1.0087 5.0742
Sd 0.0547 0.2974 0.2353 2.4049 0.0452 0.2689 0.2457 2.4929
0.1738 0.0788 0.0081 0.0049 0.0411 0.0877 0.109 0.0216
2.5259 2.3274 2.3978 2.2512 2.3523 2.4176 2.7163 2.9372
Bias -0.006 1.7e-005 -0.0019 0.0960 0.0066 0.0418 0.0087 0.0742
MSE 0.003 0.088 0.0001 0.0150 0.002 0.0018 0.0001 0.0117
(a=3,b=1)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a b a b
Mean 3.0151 1.0061 3.1538 1.0209 3.0145 1.0095 3.0364 1.0060
Sd 0.1493 0.0451 1.6009 0.2233 0.1766 0.0524 1.6409 0.2286
0.0027 -0.535 0.2121 0.2766 0.9717 0.7116 -0.290 -0.338
2.4480 3.508 2.9718 2.722 5.0290 3.7251 2.5931 2.6515
Bias 0.0151 0.0061 0.1538 0.0209 0.0145 0.0095 0.0364 0.0060
MSE 0.0003 0.002 0.0262 0.0005 0.0002 0.0001 0.0040 0.0001
75
Table 5.4: Simulation Statistics for Beta (4, 3)
Table 5.5: Simulation Statistics for Beta(3,2)
(a=4,b=3)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a B a b
Mean 4.0283 3.0102 3.999 2.9986 3.9836 2.9692 4.0362 3.0161
Sd 0.1804 0.1381 2.6090 1.7411 0.1746 0.1306 2.1844 1.3516
0.2512 0.3099 -0.0436 0.0270 0.9974 0.8995 0.3054 0.4703
2.8736 3.266 2.6150 2.7492 4.9974 4.7166 2.9499 2.8962
Bias 0.0283 0.0102 -0.0008 -0.0014 -0.016 -0.030 0.0362 0.0161
MSE 0.0008 0.0001 0.0068 0.0030 0.0003 0.0010 0.0061 0.0021
(a=3,b=2)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a B a b
Mean 2.9663 1.9860 3.0435 2.0235 3.0122 1.9965 2.9463 1.9811
Sd 0.1306 0.0923 2.3736 1.2595 0.1374 0.0949 2.6093 1.3951
0.4621 0.0964 0.0938 0.0434 0.2088 0.0861 -0.399 -0.330
2.3359 3.612 2.4233 2.6296 2.1267 2.010 3.0701 3.1817
Bias -0.033 -0.014 0.0435 0.0235 0.0122 -0.003 -0.053 -0.018
MSE 0.0012 0.0002 0.0075 0.0021 0.0002 0.009 0.0097 0.0023
76
Table 5.6: Simulation Statistics for Beta (5,1)
(a=5,b=1)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a B a b
Mean 5.0836 1.0096 4.9818 1.0011 4.9791 0.9973 5.1635 1.0265
Sd 0.3212 0.0574 1.6638 0.2332 0.2474 0.0447 1.1614 0.222
0.1310 0.0093 0.4945 0.2647 0.1757 0.1414 -0.149 -0.260
3.122 3.688 3.7453 3.4875 2.9967 2.7970 3.412 3.4515
Bias 0.0839 0.0096 -0.0182 0.0011 -0.021 -0.002 0.1635 0.0265
MSE 0.0071 0.0001 0.0031 0.0001 0.0005 0.002 0.0293 0.0008
77
5.4 GRAPHS FOR DIFFERENT SAMPLE SIZES AND PARAMETERS
FIGURE 5.1 : HISTOGRAM FOR BETA(1,5,50)
FIGURE 5.2 : HISTOGRAM FOR BETA(1,5,100)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.70
50
100
150
200
250
300
Fre
quency
Bins
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.90
50
100
150
200
250
300
350
Fre
quency
Bins
78
FIGURE 5.3: HISTOGRAM FOR BETA(3,2,50)
FIGURE 5.4: HISTOGRAM FOR BETA(3,2,100)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
20
40
60
80
100
120
140
160
180
Fre
quency
Bins
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
20
40
60
80
100
120
140
160
180
Bins
Fre
quency
79
FIGURE 5.5 :HISTOGRAM FOR BETA(3,1,50)
FIGURE 5.6: HISTOGRAM FOR BETA(3,1,100)
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
50
100
150
200
250
300
Fre
quency
Bins
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
50
100
150
200
250
300
Bins
Fre
quency
80
5.5. Beta Distribution of Second Kind
The Beta distribution of Second kind is defined by the following pdf
= 0, otherwise
Where a>0 and b>0 both are shape parameters.
The mean and variance of the distribution are
E (X) = ; V(X) =
5.6. Parameter Estimation
We are interested in estimating the parameters of the Beta distribution of second kind from
which the sample comes. Here we present the method of moments as the MLE is complex in
estimating the parameters and the Local frequency ratio method of estimation.
5.6.1 Method of moments
The rth moment about origin is
Using Beta integral, we get
81
Replacing Beta by Gamma , we get
Putting r= 1, 2, we get
…….. (5.5) ( using )
………….(5.6)
Equating the sample moments with the corresponding theoretical moments,
Solving these equations yields the following estimators:
82
5.6.2 Frequency Ratio Method of Estimation
As usual to estimate the parameters by this method, put x = x1, x2 and x3 in the Beta
distribution, we get the frequencies f1, f2 and f3
The ratio of the frequencies is
Taking logarithms on both sides,
------------------------ (5.7)
Similarly,
Taking logarithms on both sides,
83
------------------------ (5.8)
Solving (5.7) and (5.8), we get
and
We explain the above procedures in the following illustration
Illustration:
As explained earlier, we generate a sample of size 1000 from a Beta (a=2, b=4) distribution
using MATLAB function. For the generated data a frequency distribution is constructed and the
specified parameter values are estimated using above the procedures. This procedure is repeated
50 times. The mean, Standard Deviation, , and bias of these 50 estimates are computed.
The following results were obtained
Table 5.7
(a=2,b=4)
ns=50
Method of moments Frequency Ratio method
a b a b
Mean 2.0651 4.0934 2.0224 4.0010
Sd 0.2173 0.3767 1.4118 5.8261
-1.0008 -0.8184 -0.5162 -0.5124
5.5308 4.7823 3.1181 3.2351
Bias 0.0651 0.0935 0.0224 0.0010
MSE 0.055 0.1507 1.9938 33.9438
84
From the above table, we notice that the actual values of (a, b) and the mean estimated values of
(a, b) are almost same. Therefore, it can be taken as a good estimator. Similar procedure is
followed for different sample sizes and different values of (a, b). The results of both the
estimation procedures are listed in the tables 5.7 to 5.11 along with the histograms figures 5.7 to
5.12. The MATLAB programs are listed in the Appendix.
5.7 Comparison of Method of moments and Frequency Ratio Method for
Different Sample sizes and Parameters
TABLE 5.7: Simulation Statistics for Beta (2, 4)
(a=2;b=4)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a b A b
Mean 2.0651 4.0934 2.0224 4.0010 2.022 4.0389 2.0336 4.1199
Sd 0.2173 0.3767 1.4118 5.8261 0.2476 0.4002 1.7219 7.3148
-1.001 -0.818 -0.5162 -0.512 -0.395 -0.272 0.0319 0.0863
5.5308 4.7823 3.1181 3.2351 2.7567 2.5554 2.2265 2.2269
Bias 0.0651 0.0935 0.0224 0.0010 0.0225 0.0386 0.0336 0.1199
MSE 0.055 0.1507 1.9938 33.943 0.0618 0.1616 2.9653 53.5205
85
TABLE 5.8: Simulation Statistics for Beta( 3,3)
TABLE 5.9: Simulation Statistics for Beta( 3,5)
(a=3;b=3)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a b a b
Mean 3.2367 3.1924
2.9707 2.9608 3.315 3.2208 3.0410 3.0600
Sd 0.4079 0.3302 2.2200 4.2288 0.3990 0.3213 2.1180 3.8186
0.0448 0.0536 -0.4864 -0.3313 -0.571 -0.473 -0.479 -0.0722
2.2091 2.2750 2.6249 2.2182 3.2900 3.2753 3.4450 2.7652
Bias 0.2367 0.1924 -0.0293 -0.0392 0.3152 0.2208 0.0410 0.0600
MSE 0.2224 0.1460 4.993 17.8839 0.2585 0.1520 4.4879 14.5852
(a=3;b=5)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a b a b
Mean 3.0211 5.0276 3.2546 5.1656 3.0432 5.0690 3.3143 5.1878
Sd 0.2623 0.3393 0.4034 0.9808 0.2998 0.4553 0.6754 1.2952
-0.035 0.0960 0.0457 -0.1377 0.0951 0.2226 -0.719 -1.130
2.5159 2.224 2.700 3.1889 2.755 2.8137 7.3415 7.3212
Bias 0.0211 0.0276 0.2546 0.1656 0.0432 0.0690 0.3143 0.1878
MSE 0.0692 0.1583 0.2276 0.9893 0.0918 0.2121 0.5550 1.7129
86
TABLE 5.10 Simulation Statistics for Beta( 5,7)
TABLE 5.11 Simulation Statistics for Beta ( 5,10)
(a=5;b=7)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
a b a b a b a b
Mean
5.0558 7.0746 5.2022 7.1667
5.0623 7.0756 5.1557 7.0974
Sd 0.3771 0.4878 1.8331 3.1447 0.3931 0.5135 1.6845 3.1104
0.0274 0.3004 0.0133 -0.0522 0.1814 0.3812 0.1818 0.0428
2.5045 2.2683 2.3652 2.2117 2.7394 2.9302 3.4553 3.9820
Bias 0.0558
0.0746 0.2022 0.1667 0.062 0.0756 0.155 0.0974
MSE 0.1453 0.2435 3.4012 9.9172 0.1584 0.2684 2.8620 9.6840
(a=5;b=10)
ns=50 ns= 100
Method of
moments
Frequency
Ratio method
Method of
moments
Frequency
Ratio method
A b a b a b a b
Mean 5.0366 10.0662 5.1158 10.0700 5.0202 10.0296 5.224
10.3472
Sd 0.3638 0.6801 2.2092 5.6544 0.3494 0.6534 2.1881 5.3417
0.4713 0.4195 -0.974 -1.0911 0.1172 -0.0142 0.7037 0.6900
4.7670 4.8932 5.0314 5.6287 3.2497 3.0354 4.4808 3.9793
Bias 0.0366 0.0662
0.1158
0.0700 0.0202 0.0296 0.2224 0.3472
MSE 0.1337 0.4670 4.8940 31.9767 0.1225 0.4278 4.8375 28.6545
87
5.8 GRAPHS FOR DIFFERENT SAMPLE SIZES AND PARAMETERS
FIGURE 5.7: HISTOGRAM FOR BETA2(2,4,50)
FIGURE 5.8: HISTOGRAM FOR BETA2(2,4,100)
0 1 2 3 4 5 6 7 8 9 100
20
40
60
80
100
120
140
Fre
quency
Bins
0 2 4 6 8 10 12 14 160
20
40
60
80
100
120
140
Bins
Fre
quency
88
FIGURE 5.9: HISTOGRAM FOR BETA2 (3,3,50)
FIGURE 5.10: HISTOGRAM FOR BETA2 (3,3,100)
0 5 10 15 20 250
20
40
60
80
100
120
140
Fre
quency
Bins
0 2 4 6 8 10 12 14 160
50
100
150
Fre
quency
Bins
89
FIGURE 5.11: HISTOGRAM FOR BETA2 (5,7,50)
FIGURE 5.12: HISTOGRAM FOR BETA2 (5,7,100)
0 1 2 3 4 5 60
50
100
150
200
250
300
0 0.5 1 1.5 2 2.5 3 3.5 40
50
100
150
200
250
90
MATLAB PROGRAMS
BETA DISTRIBUTION OF FIRST KIND %PROGRAM TO ESTIMATE THE PARAMETERS BY METHOD OF MOMENTS AND
LOCAL FREQUENCY RATIO METHOD.
%n (sample size);ns(%no of samples);k=no. of classes(bins
created)
%n=1000; ns=100;k=10;a=3;b=1;
for j=1:ns,
ex=betarnd(a,b,n,1);
meanx = mean(ex);
varx = var(ex);
t=((meanx.*(1-meanx))./varx)-1;
aa(j)=meanx* t;
bb(j) = t-aa(j);
maxx=max(ex);
h=maxx/k;
[fr,r]=hist(ex,h/2:h:maxx);
hist(ex,h/2:h:maxx)
[u,v]=sort(fr);
u=fliplr(u);
v=fliplr(v);
y=v(1:3);x=r(y);
f=u(1:3);
91
x1=1-x(1);
x2=1-x(2);
x3 = 1-x(3);
x12=log(x(1)/x(2));
x23=log(x(2)/x(3));
lx12 = log(x1/x2);
lx23=log(x2/x3);
lf12=log(f(1)/f(2));
lf23=log(f(2)/f(3));
em=[x12,lx12;x23,lx23];
rhs=[lf12;lf23];
est=em\rhs;
aest=est(1)+1;
best=est(2)+1;
a1(j)=aest;
b1(j)=best;
clear ex fr r u v ;
end
%LOCAL FREQUENCY METHOD
a1=a1; b1=b1;
ma1=mean (a1); sda1=std (a1); mb1=mean (b1); sdb1=std (b1);
a1z= (a1-ma1)/sda1; b1z= (b1-mb1)/sdb1;
rba1=mean (a1z. ^3); b2a1=mean (a1z. ^4);
rbb1=mean (b1z. ^3); b2b1=mean (b1z. ^4);
92
%bias
ba1=a1-a; mba1=mean (ba1);bb1=b1-b;mbb1=mean(bb1);
%mean square error
msea1=sda1^2+ mba1^2; mseb1=sdb1^2+ mbb1^2;
Local moments = [ma1, sda1, rba1, b2a1, mb1, sdb1,rbb1, b2b1]
locbias=[mba1,msea1,mbb1,mseb1]
%By Method of Moments
a2= aa; b2=bb;
ma2=mean (a2); sda2=std(a2);
mb2=mean (b2); sdb2=std(b2);
a2z= (a2-ma2)/sda2; b2z=(b2-mb2)/sdb2;
rba2=mean (a2z. ^3);b2a2=mean(a2z.^4);
rbb2=mean (b2z.^3);b2b2=mean(b2z.^4);
%bias
ba2=a2-a; mba2= mean (ba2);bb2=b2-b;mbb2=mean(bb2);
%mean square error
msea2=sda2^2+ mba2^2; mseb2=sdb2^2+ mbb2^2;
methodofmoments = [ma2, sda2,rba2,b2a2,mb2, sdb2,rbb2,b2b2]
mombias = [mba2,msea2,mbb2,mseb2]
93
BETA DISTRIBUTION OF SECOND KIND
%PROGRAM TO ESTIMATE THE PARAMETERS BY METHOD OF MOMENTS AND
LOCAL FREQUENCY RATIO METHOD.
n=1000; ns=100;k=19;a=5;b=10;
for j=1:ns,
x=betarnd (a, b, n, 1);
ex=x./(1-x);
Meanx = mean(ex);
varx = var(ex);
t=((meanx*(1+meanx))./varx)+1;
aa(j)=meanx* t;
bb(j) = t+1;
maxx=max(ex);
h=maxx/k;
[fr,r]=hist(ex,h/2:h:maxx);
hist(ex,h/2:h:maxx)
[u,v]=sort(fr);
u=fliplr(u);
v=fliplr(v);
y=v(1:3);x=r(y);
f=u(1:3);
x1=1+x(1);
x2=1+x(2);
94
x3 = 1+x(3);
x12=log(x(1)/x(2));
x23=log(x(2)/x(3));
lx12 = log(x2/x1);
lx23=log(x3/x2);
lf12=log(f(1)/f(2));
lf23=log(f(2)/f(3));
em=[x12,lx12;x23,lx23];
rhs=[lf12;lf23];
est=em\rhs;
aest=est(1)+1;
best=est(2)-aest;
a1(j)=aest;
b1(j)=best;
clear ex fr r u v ;
end
%LOCAL METHOD
a1=a1;b1=b1;
ma1=mean(a1);sda1=std(a1);
mb1=mean(b1);sdb1=std(b1);
a1z=(a1-ma1)/sda1;b1z=(b1-mb1)/sdb1;
rba1=mean(a1z.^3);b2a1=mean(a1z.^4);
rbb1=mean(b1z.^3);b2b1=mean(b1z.^4);
95
%bias
ba1=a1-a;mba1=mean(ba1);
bb1=b1-b;mbb1=mean(bb1);
%mean square error
msea1=sda1^2+ mba1^2;
mseb1=sdb1^2+ mbb1^2;
local moments = [ma1, sda1,rba1,b2a1,mb1,sdb1,rbb1,b2b1]
locbias=[mba1,msea1,mbb1,mseb1]
%By Method of Moments
a2=aa;b2=bb;
ma2=mean(a2);sda2=std(a2); mb2=mean(b2);sdb2=std(b2);
a2z=(a2-ma2)/sda2;b2z=(b2-mb2)/sdb2;
rba2=mean(a2z.^3);b2a2=mean(a2z.^4);
rbb2=mean(b2z.^3);b2b2=mean(b2z.^4);
%bias
ba2=a2-a;mba2=mean(ba2);
bb2=b2-b;mbb2=mean(bb2);
%mean square error
msea2=sda2^2+ mba2^2;
mseb2=sdb2^2+ mbb2^2;
methodofmoments = [ma2, sda2,rba2,b2a2,mb2, sdb2,rbb2,b2b2]
mombias = [mba2,msea2,mbb2,mseb2]