Post on 23-Jun-2020
transcript
96
Pareto and Laplace Distributions
In this chapter we consider the Pareto distribution and Laplace distribution (double exponential
distribution)
6.1. The Pareto distribution
The Pareto distribution is a Continuous probability distribution named after the economist
Vilfredo Pareto.
The Pareto distribution is defined by the following functions:
PDF :
= 0 ,otherwise
CDF :
The parameter k marks a lower bound on the possible values that a Pareto distributed random
Variable can take on.
The mean and variance of Pareto distribution are:
97
The Pareto distribution has been used to represent the income distribution of a society. It is also
used to model many phenomena such as city population sizes, occurrence of natural resources,
stock price fluctuations, size of firms, and brightness of comets.
6.2. Parameter Estimation
We are interested in estimating the parameters of the Pareto distribution from which the
sample comes. Here we present the Method of Moments, Method of Maximum Likelihood
Estimation and the Local frequency ratio method of estimation.
6.2.1 Method of moments
The rth
moment about origin is
Put r = 1, we get the first raw moment
……………(6.1)
Put r =2 , we get the second raw moment
98
……….. (6.2)
Solving (6.1) and (6.2) ,we have the following estimators:
and
6.2.2 Maximum Likelihood Estimation
Let be a random sample of n observations from the Pareto population with pdf
The likelihood function of this sample is
;
Taking logarithms on both sides
The likelihood equation is = 0
On simplification, we get
99
For this distribution, the shift parameter k cannot be estimated under MLE, because it leads to an absurd
estimate k = .For the shift parameter, this seems to be in general, the case for one sided distributions of
the type that one ordinarily encounters. Hence in these cases one can use sample minimum as an estimate
of the shift parameter.
6.2.3 Frequency Ratio Method of Estimation
We now estimate the parameters by considering local frequency ratio method by
putting x = x1, x2 in the Pareto distribution , we get
and
The ratio of the frequencies is
Taking logarithms on both sides, we get
and
100
Illustration:
As explained earlier, we generate a sample of size 1000 from a Pareto (a=3, k=1)
distribution using MATLAB function. For the generated data the following frequency
distribution is obtained.
x
1.2501 1.7501 2.2501 2.7501 3.2501
f
677 193 72 28 0
Using these values in the above formula, the estimated value of a is
The above procedure is repeated for 50 samples. The mean, Standard deviation , , bias of
these 50 estimates 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 .
TABLE 6.1
K=1;a=3 ns = 50
Method of
moments
Maximum
Likelihood
Frequency Ratio
Method a k a k a k
Mean 3.2064 1.0278 2.9937 1.0004 3.1496 1.0004
Sd 0.3585 0.0482 0.1010 0.0004 0.2469 0.0004
0.4106 1.1852 0.4220 1.4256 0.3798 1.4256
2.9936 4.3673 3.2226 4.4269 3.3016 4.4269
Bias 0.2064 0.0278 -0.0063 0.0004 0.1496 0.0004
MSE 0.1711 0.0031 0.0102 0.0000 0.0834 0.0000
101
From the above table, we notice that the actual values of (a, k) and the mean estimated values of
(a,k) 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, k) and are listed in the tables 6.2 to
6.9 and the histograms in the figures 6.1 to 6.8 .The MATLAB programs are listed in the
Appendix.
6.3 Comparison of Method of Moments, Method of MLE and Frequency Ratio
Method for Different sample sizes and Different parameters:
TABLE 6.2 SIMULATION STATISTICS FOR PARETO(3,1,100)
TABLE 6.3 SIMULATION STATISTICS FOR PARETO (3,1,200)
K=1;a=3 ns = 100
Method of
moments
Maximum
Likelihood
Frequency Ratio
Method a K a k a k
Mean 3.2670 1.0377 3.0017 1.0003 3.1478 1.0003
Sd 0.3981 0.0580 0.0979 0.0003 0.2748 0.0003
0.6866 2.0851 0.1785 1.2986 0.4619 1.2986
3.6152 8.7724 2.9173 4.1652 2.8449 4.1652
Bias 0.2670 0.0327 0.0017 0.0003 0.1478 0.0003
MSE 0.2298 0.0044 0.0096 0.000 0.0974 0.000
K=1;a=3 ns = 200
Method of
moments
Maximum
Likelihood
Frequency Ratio
Method a k a k a k
Mean 3.2657 1.0317 3.0098 1.0003 3.1985 1.0003
Sd 0.3979 0.0528 0.0966 0.0003 0.2415 0.0003
0.5345 1.7159 0.3035 1.6101 0.1710 1.6101
3.1307 6.5251 3.2694 5.6326 2.6308 5.6326
Bias 0.2657 0.0317 0.0098 0.0003 0.1985 0.0003
MSE 0.2289 0.0038 0.0094 0.0000 0.0977 0.0000
102
TABLE 6.4 SIMULATION STATISTICS FOR PARETO(5,10,50)
TABLE 6.5 SIMULATION STATISTICS FOR PARETO(5,10,100)
K=10;a=5 ns =50
Method of
moments
Maximum Likelihood Frequency Ratio
Method
a k a k a k
Mean 4.9345 9.9662 4.9835 10.0019 5.4030 10.0019
Sd 0.3443 0.1376 0.1563 0.0019 0.3534 0.0019
0.0087 -0.5740 0.0651 1.8182 0.4410 1.8182
2.5867 2.7132 2.7175 6.8251 2.8721 6.8251
Bias -0.0655
-0.0338 -0.0165 0.0019 0.4358 0.0019
MSE 0.0044 0.0012 0.0003 3.76e-006 0.1901 3.76e-006
K=10;a=5 ns = 100
Method of
moments
Maximum Likelihood Frequency Ratio
Method
a k a k a k
Mean 4.9345 9.9662 4.9835 10.002 5.4030 10.002
Sd 0.3443 0.1376 0.1563 0.0017 0.3534 0.0017
0.0087 -0.5740 0.0651 1.1698 0.4410 1.1698
2.5867 2.7132 2.7175 4.2560 2.8721 4.2560
Bias -0.0655 -0.0338 -0.0165 0.0020 0.4030 0.0020
MSE 0.0044 0.0012 0.0003 3.93e-006 0.1625 3.93e-006
103
TABLE 6.6 SIMULATION STATISTICS FOR PARETO(5,10,200)
TABLE 6.7 SIMULATION STATISTICS FOR PARETO (3,4,50)
K=10;a=5
ns = 200
Method of
moments
Maximum Likelihood Frequency Ratio
Method
a k a k a k
Mean 4.9161 9.9523 4.9934 10.0019 5.4156 10.0019
Sd 0.3390 0.1554 0.1618 0.0019 0.3240 0.0019
-0.3448 -0.9485 0.1258 1.5016 0.2530 1.5016
3.4192 4.7027 3.1781 5.1698 3.2370 5.1698
Bias -0.0839 -0.0477 -0.0066 0.0019 0.4156 0.0019
MSE 0.0072 0.0023 0.0001 0.0000 0.1729 0.0000
K=4;a=3 ns = 50
Method of
moments
Maximum Likelihood Frequency Ratio
Method
a k a k a k
Mean 2.9221 3.9224 3.0154 4.0018 3.1798 4.0018
Sd 0.2424 0.1480 0.0849 0.0018 0.2453 0.0018
-0.1334 -0.3781 0.1308 1.1341 0.3441 1.1341
1.9689 2.2147 2.4638 3.3688 2.5521 3.3988
Bias -0.0779 -0.0779 0.0154 0.0018 0.1798 0.0018
MSE 0.0061 0.0061 0.0002 3.34e-006 0.0324 3.34e-006
104
TABLE 6.8 SIMULATION STATISTICS FOR PARETO(3,4,100)
TABLE 6.9 SIMULATION STATISTICS FOR PARETO (3,4,200)
K=4;a=3 ns = 100
Method of moments Maximum Likelihood Frequency Ratio
Method
A k a k a k
Mean 2.9445 3.9346 3.0000 4.0014 3.1930 4.0014
Sd 0.2717 0.1683 0.1006 0.0013 0.2626 0.0013
-0.1711 -1.1393 0.0270 1.4220 -0.2190 1.4220
3.0482 5.1894 2.3433 6.0989 2.4703 6.0989
Bias -0.0555 -0.0654 4.15e-005 0.0014 0.1930 0.0014
MSE 0.0032 0.0043 1.01e-005 1.86e-006 0.0373 1.86e-006
K=4;a=3 ns = 200
Method of moments Maximum Likelihood Frequency Ratio
Method
A k a k a k
Mean 2.8898
3.8911
3.0047
4.0013
3.1855
4.0013
Sd 0.3320
0.2376
0.0958 0.0011 0.2590 0.0011
-0.6307
-1.7891
-0.0263 1.1865 0.3217 1.1865
3.4086
7.4399
2.8725 4.0392 3.2658 4.0392
Bias -0.1102
-0.1089
0.0047 0.0013 0.1855 0.0013
MSE 0.0123 0.0119 3.11e-005 1.58e-006 0.0345 1.58e-006
105
6.4 GRAPHS FOR DIFFERENT SAMPLE SIZES AND DIFFERENT PARAMETERS
FIGURE 6.1 HISTOGRAM FOR PARETO (3,1,50)
FIGURE 6.2 HISTOGRAM FOR PARETO (3,1,100)
0.5 1 1.5 2 2.5 3 3.50
50
100
150
200
250
300
350
400
450
500
Bins
Fre
quency
0.5 1 1.5 2 2.5 3 3.50
50
100
150
200
250
300
350
400
450
500
Bins
Fre
quency
106
FIGURE 6.3 HISTOGRAM FOR PARETO (3,1, 200)
FIGURE 6.4 HISTOGRAM FOR PARETO (5, 10, 50 )
0.5 1 1.5 2 2.5 3 3.50
50
100
150
200
250
300
350
400
450
500
Bins
Fre
quency
5 10 15 20 25 30 350
100
200
300
400
500
600
700
Bins
Fre
quency
107
FIGURE 6.5 HISTOGRAM FOR PARETO (5,10, 100)
FIGURE 6.6. HISTOGRAM FOR PARETO ( 5, 10, 200)
5 10 15 20 25 30 350
100
200
300
400
500
600
700
Bins
Fre
quency
5 10 15 20 25 30 350
100
200
300
400
500
600
700
Bins
Fre
quency
108
FIGURE 6.7. HISTOGRAM FOR PARETO (3,4, 50)
FIGURE 6.8. HISTOGRAM FOR PARETO (3, 4, 100)
2 4 6 8 10 12 140
50
100
150
200
250
300
350
400
450
500
Fre
quency
Bins
2 4 6 8 10 12 140
50
100
150
200
250
300
350
400
450
500
Bins
Fre
quency
109
6.5. Laplace Distribution (Double Exponential Distribution)
The Laplace distribution is a Continuous probability distribution named after
Pierre-Simon Laplace. It is also sometimes called the Double Exponential Distribution because it
consists of two exponential distributions (with an additional location parameter) spliced peak to
peak.
The Laplace distribution is defined by the following functions:
PDF :
= 0 , otherwise
CDF :
Where is the location parameter and is the scale parameter.
The case where = 0 and = 1 is called the standard double exponential
distribution. The equation for the standard double exponential distribution is
,
The Laplace distribution has found uses in fields where an alternative to
the Normal distribution that has longer tails and a more pronounced peak is desired. The three
fields with the most prolific use of the Laplace distribution are navigation (particularly in
modeling nautical errors), finance (particularly in forecasting returns on commodities), and
110
speech recognition (particularly in modeling natural acoustic noise).Beyond this, the Laplace
distribution is slowly finding more relevance in fields such as energy engineering though
extended use of the distribution is rare.
The following is the plot of the Laplace (Double Exponential Distribution) probability density
function.
Properties of the distribution are :
1) Mean =Median = Mode =
2) Variance = 2
3) Skewness = 0 and Kurtosis = 3.
6.6. Parameter Estimation
We are interested in estimating the parameters of the Laplace distribution from which the
sample comes. Here we present the Method of Maximum Likelihood Estimation and the Local
frequency ratio method of estimation.
111
6.6.1 Maximum Likelihood Estimation
Let be a random sample of n observations from the population with pdf
The likelihood function of this sample is
;
Taking logarithms on both sides
The likelihood equation for estimating
Now, = Least absolute estimator to take the derivative of L.
To estimate consider
112
Now,
Therefore,
Which is zero if the same numbers of xi are less than as greater than . Therefore ,if n is
even, we choose to be any value between n/2 th and (n/2 + 1)th of the sorted values of x and
if n is odd we choose to be middle value of x . In other words, the MLE for is median
6.6.2 Frequency Ratio Method of Estimation
In this section ,we explain the local Frequency ratio method of estimation by taking x = x1,x2
in the pdf of Laplace distribution ,we get
(taking
Taking logarithms on both sides
113
Illustration:
As explained earlier, we generate a sample of size 1000 from a Laplace (α=2, β=3) distribution
using MATLAB function. For the generated data the following frequency distribution is
obtained.
Since the Laplace distribution is symmetric, the maximum frequency contains median. To estimate the β,
we take the frequencies to right of maximum frequency i.e.., 296 and 108 .Using the above formula, we
get
And the parameter α is estimated in the usual way.
The above procedure is repeated for 50 samples. The mean, Standard deviation , , bias
of these 50 estimates were computed. The estimated bias and Mean Squared Error (MSE) was
calculated as discussed in the chapter3.
x
(mid-value) -13.52 -9.952 -6.383 -2.815 0.7537 4.322 7.890 11.459 15.028 18.597
f 3 8 27 117 397 296 108 30 9 5
114
From the above table, we notice that the actual values of( ) and the mean estimated values of
( ) are almost same. Therefore, it can be taken as a good estimator. Similar procedure is
followed for different sample sizes and different values of ( ) . The Simulation results are
tabulated in tables 6.10 to 6.15 and the corresponding histograms in the figures 6.9 to 6.16.The MATLAB
programs are listed in the Appendix.
6.7 COMPARISION OF METHOD OF MOMENTS, MAXIMUM LIKELIHOOD ESTIMATION
METHOD AND FREQUENCY RATIO METHOD.
TABLE 6.10: SIMULATION STATISTICS FOR LAPLACE (1,3)
(α=2, β=3)
ns=50
MLE Frequency Ratio method
Mean 3.2210 1.9970 2.9259 2.0153
Sd 0.0812 0.0812 0.3516 0.2022
0.0962 -0.0962 0.3609 0.3609
2.8833 2.8833 2.7260 3.0897
Bias 0.2210 -0.0030 -0.0741 0.0153
MSE 0.0554 0.0066 0.1291 0.0411
(α=1,
β=3)
ns=50 ns= 100
MLE Frequency
Ratio method
MLE Frequency
Ratio method
Mean 3.0945 1.0193 2.9898 1.0012 2.8494 1.006 3.0261 0.9886
Sd 0.0841 0.0841 0.3916 0.2798 0.100 0.100 0.4614 0.3169
-0.0414 0.0414 -0.5173 0.3006 0.0523 0.0523 0.5982 -1.0276
3.6052 3.6052 3.3482 4.3686 2.3514 2.3514 2.7809 4.8522
Bias 0.0945 0.0193 -0.0102 0.0012 -0.1506 0.0061 0.0261 -0.0114
MSE 0.0160 0.0074 0.1535 0.0783 0.0327 0.0100 0.2136 0.1006
115
TABLE 6.11: SIMULATION STATISTICS FOR LAPLACE (2,1)
TABLE 6.12: SIMULATION STATISTICS FOR LAPLACE(2,5)
(α=2,
β=1)
ns=50 ns= 100
MLE Frequency
Ratio method
MLE Frequency
Ratio method
Mean 0.9742 2.0031 0.9820 2.0164 0.9991 2.0022 1.0017 2.0082
Sd 0.0394 0.0394 0.1380 0.0880 0.0330 0.0330 0.1101 0.0786
0.3231 -0.3231 0.6411 -0.4466 -0.0947 -0.0947 0.0734 -0.4123
2.7522 2.7522 3.1520 3.3254 2.7857 2.7857 2.3102 3.4942
Bias -0.0258 0.0031 -0.0180
0.0164 -0.0009 0.0022 0.0017 0.0082
MSE 0.0022 0.0016 0.0194 0.0082 0.0011 0.0011 0.0121 0.0062
(α=2,
β=5)
ns=50 ns= 100
MLE Frequency
Ratio method
MLE Frequency
Ratio method
Mean 4.8712 2.0157 4.9098 2.0818
4.9955
2.0112 5.0086 2.0408
Sd 0.1968 0.1968 0.6898 0.4402 0.1651 0.1651 0.5506 0.3930
0.3231 -0.3231 0.6411 -0.4466 -0.0947 0.0947 0.0734 -0.4123
2.7522 2.7522 3.1520 3.3254 2.7857 2.7857 2.3102 3.4942
Bias -0.1288 0.0157 -0.0902 0.0818 -0.0045 0.0112 0.0086 0.0408
MSE 0.0553 0.0390 0.4839 0.2005 0.0273 0.0274 0.3033 0.1561
116
TABLE 6.13 : SIMULATION STATISTICS FOR LAPLACE(3,2)
TABLE 6.14 : SIMULATION STATISTICS FOR LAPLACE(5,10)
(α=3,
β=2)
ns=50 ns= 100
MLE Frequency
Ratio method
MLE Frequency
Ratio method
Mean 2.1707 2.9939 1.9876 3.0056 2.1552 2.9958
2.0483
2.9905
Sd 0.0693 0.0693 0.2109 0.1381 0.0630 0.0630 0.2392 0.1356
-0.2256 0.2256 0.3115 0.3354 0.0141 -0.0141 0.6487 -0.2359
2.6244 2.6244 2.2903 2.0202 2.7078 2.7078 2.9248 3.9061
Bias 0.1707 -0.0061 -0.0124 0.0056 0.1552 -0.0042 0.0483 -0.0095
MSE 0.0339 0.0048 0.0445 0.0191 0.0281 0.0040 0.0596 0.0185
(α=5,
β=10)
ns=50 ns= 100
MLE Frequency
Ratio method
MLE Frequency
Ratio method
Mean 9.8130 4.9585 10.0074 4.9291 10.0096 4.9820 9.9691 5.0060
Sd 0.3226 0.3226 1.1254 0.7442 0.3118 0.3118 1.1415 0.6644
0.2986 -0.2986 0.6854 -0.8880 -0.3165 0.3165 0.7413 -0.0305
2.5252 2.5252 3.3718 4.2571 3.0856 3.0856 3.7075 2.9563
Bias -0.1870
-0.0415 0.0074 -0.0709 0.0096 -0.0180 -0.0309 0.0060
MSE 0.1390 0.1058 1.2665 0.5588 0.0973 0.0976 1.3039 0.4415
117
TABLE 6.15 : SIMULATION STATISTICS FOR LAPLACE(5,5)
(α=5,
β=5)
ns=50 ns= 100
MLE Frequency
Ratio method
MLE Frequency
Ratio method
Mean 5.0607 4.9999 5.0477 4.9757 4.9789 5.0274 5.0715 4.9991
Sd 0.1652 0.1652 0.4245 0.2905 0.1424 0.1454 0.6687 0.3682
0.5854 -0.5854 -0.4897 0.7658 0.1472 -0.1472 0.6201 -0.3775
3.3466 3.3466 2.4426 2.9670 2.7298 2.7298 3.4584 3.2357
Bias 0.0607 -0.0001 0.0477 -0.0243 -0.0211 0.0274 0.0715 -0.0009
MSE 0.0310 0.0273 0.1825 0.0850 0.0207 0.0210 0.4523 0.1356
118
6.8 GRAPHS FOR DIFFERENT SAMPLE SIZES AND DIFFERENT PARAMETERS
FIGURE 6.9 : HISTOGRAM FOR LAPLACE(1,2,50)
FIGURE 6.10 : HISTOGRAM FOR LAPLACE (1,2,100)
-25 -20 -15 -10 -5 0 5 10 150
100
200
300
400
500
600
Bins
Fre
quency
-15 -10 -5 0 5 10 15 200
50
100
150
200
250
300
350
400
450
500
Fre
quency
Bins
119
FIGURE 6.11: HISTOGRAM FOR LAPLACE (2, 3,50)
FIGURE 6.12: HISTOGRAM FOR LAPLACE (2, 3,100)
-20 -15 -10 -5 0 5 10 15 20 250
50
100
150
200
250
300
350
400
450
500
Fre
quency
Bins
-20 -15 -10 -5 0 5 10 15 20 250
50
100
150
200
250
300
350
400
Fre
quency
Bins
120
FIGURE 6.13: HISTOGRAM FOR LAPLACE (5, 2, 50)
FIGURE 6.14: HISTOGRAM FOR LAPLACE (5, 2,100)
-10 -5 0 5 10 15 200
50
100
150
200
250
300
350
400
450
Fre
quency
Bins
-10 -5 0 5 10 15 200
50
100
150
200
250
300
350
400
Bins
Fre
quency
121
FIGURE 6.15: HISTOGRAM FOR LAPLACE (5, 5, 50)
FIGURE 6.16: HISTOGRAM FOR LAPLACE (5, 5,100)
-30 -20 -10 0 10 20 30 400
50
100
150
200
250
300
350
400
450
Fre
quency
Bins
-40 -30 -20 -10 0 10 20 30 40 500
50
100
150
200
250
300
350
400
450
500
Fre
quency
Bins
122
MATLAB PROGRAMS
PARETO DISTRIBUTION
% PROGRAM TO FIND THE ESTIMATES OF PARAMETER BY METHOD OF
MOMENTS,MLE AND FREQUENCY RATIO METHOD.
nnska=input('enter n ns k and a as a 4-Vector.');
n=nnska(1);ns=nnska(2);k=nnska(3);a=nnska(4);
%n=1000;ns=200;a=1;k=1;
for i=1:ns,
x=k./((rand(n,1).^(1/a)));
mx=mean(x);varx=var(x);
k0(i)=min(x);
k2(i)=min(x);
a2(i)=n./(sum(log(x./k2(i))));
h=k0(i)/2;
[f,z]=histc(x,k0(i):h:3*k0(i));
hist(x,k0(i):h:3*k0(i))
f1=f(1);f2=f(2);
lf12=log(f1/f2);
x1=k0(i)+h/2;
x2=x1+h;
lx21=log(x2/x1);
a0(i)=(lf12/lx21)-1;
a1(i)=1+sqrt((1+mx*mx)/varx);
123
k1(i)=(mx*(a1(i)-1))/a1(i);
end
a2=a2;k2=k2;k0=k0;k1=k1;a1=a1;a0=a0;
%method of moments
ma1=mean(a1);mk1=mean(k1);
sda1=std(a1);sdk1=std(k1);
a1z=(a1-ma1)/sda1;k1z=(k1-mk1)/sdk1;
rb1a1=mean(a1z.^3);b2a1=mean(a1z.^4);
rb1k1=mean(k1z.^3);b2k1=mean(k1z.^4);
ba1=a1-a;mba1=mean(ba1);
bk1=k1-k;mbk1=mean(bk1);
msea1=sda1^2+ mba1^2;
msek1=sdk1^2+ mbk1^2;
mom = [ma1,sda1,rb1a1,b2a1,mk1,sdk1,rb1k1,b2k1]
mombias = [mba1,msea1,mbk1,msek1]
%maximum likelihood estimation
ma2=mean(a2);mk2=mean(k2);
sda2=std(a2);sdk2=std(k2);
a2z=(a2-ma2)/sda2;k2z=(k2-mk2)/sdk2;
rb1a2=mean(a2z.^3);b2a2=mean(a2z.^4);
rb1k2=mean(k2z.^3);b2k2=mean(k2z.^4);
ba2=a2-a;mba2=mean(ba2);
bk2=k2-k;mbk2=mean(bk2);
msea2=sda2^2+ mba2^2;
124
msek2=sdk2^2+ mbk2^2;
mle = [ma2,sda2,rb1a2,b2a2,mk2,sdk2,rb1k2,b2k2]
mlebias = [mba2,msea2,mbk2,msek2]
%local frequency ratio method
ma0=mean(a0);mk0=mean(k0);
sda0=std(a0);sdk0=std(k0);
a0z=(a0-ma0)/sda0;k0z=(k0-mk0)/sdk0;
rb1a0=mean(a0z.^3);b2a0=mean(a0z.^4);
rb1k0=mean(k0z.^3);b2k0=mean(k0z.^4);
ba0=a0-a;mba0=mean(ba0);bk0=k0-k;mbk0=mean(bk0);
msea0=sda0^2+mba0^2;msek0=sdk0^2+mbk0^2;
local = [ma0,sda0,rb1a0,b2a0,mk0,sdk0,rb1k0,b2k0]
lobias=[mba0,msea0,mbk0,msek0]
DOUBLE EXPONENTIAL DISTRIBUTION
%PROGRAM TO ESTIMATE THE PARAMETERS BY MLE AND LOCAL FREQUENCY
RATIO METHOD.
nsm=input('enter nsm,ssize,scale and loc params as a 30vector.')
n=nsm(1);s=nsm(2);m=nsm(3);
%ns=50;n=1000;s=5;m=5;
tic,
x0=exprnd(s,n,ns);
125
r=rand(n,ns)<.5;
ex=(x0.*r-x0.*(1-r))+m;
k1=0;k2=0;k=0;
for i=1:ns,
x=ex(:,i);
y=sort(x);
medx(i)=median(x);
meanx=mean(x); hist(x),
n2=ceil(n/2);
ris=((mean(y(n2:end))-medx));
% les = (-(mean(y(1:(n2-1))-medx)));
[f0,z]=hist(x);%h=(max(x)-min(x))/10;
[u,v]=max(f0);
f2=u;
x2=z(v);
x1=z(v-1);
x3=z(v+1);
x4=z(v+2);
f1=f0(v-1);
f3=f0(v+1);
f4=f0((v+2));
f1234=[f1 f2 f3 f4];
g(i)=f1*f3*f4==0;
f13=f1/f3;
126
f34=f3/f4;
lf13=log(f13);
lf34=log(f34);
x1p3=x1+x3;
x4m3=x4-x3;
sest=x4m3/lf34;
mest=(x1p3-sest*lf13)/2;
s2(i) = sest;m2(i)=mest;
end
%Maximum Likelihood Estimation
s1=ris;m1=medx;
ms1=mean(s1);sds1=std(s1);
mm1=mean(m1);sdm1=std(m1);
s1z=(s1-ms1)/sds1;m1z=(m1-mm1)/sdm1;
rbs1=mean(s1z.^3);b2s1=mean(s1z.^4);
rbm1=mean(m1z.^3);b2m1=mean(m1z.^4);
%bias
bs1=s1-s;mbs1=mean(bs1);
bm1=m1-m;mbm1=mean(bm1);
%mean square error
mses1=sds1^2+ mbs1^2;
msem1=sdm1^2+ mbm1^2;
MLE = [ms1,sds1,rbs1,b2s1,mm1,sdm1,rbm1,b2m1]
mlebias=[mbs1,mses1,mbm1,msem1]
127
%By FREQUENCY RATIO METHOD
s2=s2;m2=m2;
ms2=mean(s2);sds2=std(s2);
mm2=mean(m2);sdm2=std(m2);
s2z=(s2-ms2)/sds2;m2z=(m2-mm2)/sdm2;
rbs2=mean (s2z.^3);b2s2=mean(s2z.^4);
rbm2=mean (m2z.^3);b2m2=mean(m2z.^4);
%bias
bs2=s2-s; mbs2=mean (bs2);bm2=m2-m;mbm2=mean(bm2);
%mean square error
mses2=sds2^2+ mbs2^2; msem2=sdm2^2+ mbm2^2;
Local = [ms2, sds2, rbs2, b2s2,mm2, sdm2,rbm2,b2m2]
Local bias = [mbs2, mses2,mbm2, msem2]