Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PDF[TransformedDistribution[x z, {x [Distributed] ExponentialDistribution[[Lambda]],
- z [Distributed] NormalDistribution[0, 1]}], y]
- (* Generate some data *)
- SeedRandom[12345];
- [Lambda]0 = 3;
- n = 100;
- x = RandomVariate[ExponentialDistribution[[Lambda]0], n];
- z = RandomVariate[NormalDistribution[], n];
- y = x z;
- (* Log likelihood *)
- logL = n Log[[Lambda]] - (3 n/2) Log[2] - n Log[[Pi]] +
- Sum[Log[MeijerG[{{}, {}}, {{0, 0, 1/2}, {}}, (
- y[[i]]^2 [Lambda]^2)/8]], {i, n}];
- (* Method of moments estimate *)
- [Lambda]Initial = Sqrt[2]/StandardDeviation[y]
- (* 3.159259259137787 *)
- (* Maximum likelihood estimate *)
- mle = FindMaximum[{logL, [Lambda] > 0}, {[Lambda], [Lambda]Initial}]
- (* {33.75465530200371,{[Lambda] -> 2.7946001175877813}} *)
- (* Alternative (but slower) *)
- (* mle=NMaximize[{logL,[Lambda]>0},[Lambda],Method -> "SimulatedAnnealing"] *)
- (* Check to see if first partial derivative is approximately zero *)
- dlogL[Lambda] = D[logL, [Lambda]] /. mle[[2]]
- (* 1.000782830828939 * 10^(-6) *)
- (* Estimate of standard error *)
- se = Sqrt[-1/(D[logL, {[Lambda], 2}]) /. mle[[2]]]
- (* 0.39489891632730545 *)
- (* Another check: plot the log likelihood *)
- Plot[logL, {[Lambda], 1, 4}, Frame -> True, FrameLabel -> {"[Lambda]", "Log(likelihood)"}]
Add Comment
Please, Sign In to add comment