Guest User

Untitled

a guest
Jul 17th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. PDF[TransformedDistribution[x z, {x [Distributed] ExponentialDistribution[[Lambda]],
  2. z [Distributed] NormalDistribution[0, 1]}], y]
  3.  
  4. (* Generate some data *)
  5. SeedRandom[12345];
  6. [Lambda]0 = 3;
  7. n = 100;
  8. x = RandomVariate[ExponentialDistribution[[Lambda]0], n];
  9. z = RandomVariate[NormalDistribution[], n];
  10. y = x z;
  11.  
  12. (* Log likelihood *)
  13. logL = n Log[[Lambda]] - (3 n/2) Log[2] - n Log[[Pi]] +
  14. Sum[Log[MeijerG[{{}, {}}, {{0, 0, 1/2}, {}}, (
  15. y[[i]]^2 [Lambda]^2)/8]], {i, n}];
  16.  
  17. (* Method of moments estimate *)
  18. [Lambda]Initial = Sqrt[2]/StandardDeviation[y]
  19. (* 3.159259259137787 *)
  20.  
  21. (* Maximum likelihood estimate *)
  22. mle = FindMaximum[{logL, [Lambda] > 0}, {[Lambda], [Lambda]Initial}]
  23. (* {33.75465530200371,{[Lambda] -> 2.7946001175877813}} *)
  24. (* Alternative (but slower) *)
  25. (* mle=NMaximize[{logL,[Lambda]>0},[Lambda],Method -> "SimulatedAnnealing"] *)
  26.  
  27. (* Check to see if first partial derivative is approximately zero *)
  28. dlogL[Lambda] = D[logL, [Lambda]] /. mle[[2]]
  29. (* 1.000782830828939 * 10^(-6) *)
  30.  
  31. (* Estimate of standard error *)
  32. se = Sqrt[-1/(D[logL, {[Lambda], 2}]) /. mle[[2]]]
  33. (* 0.39489891632730545 *)
  34.  
  35. (* Another check: plot the log likelihood *)
  36. Plot[logL, {[Lambda], 1, 4}, Frame -> True, FrameLabel -> {"[Lambda]", "Log(likelihood)"}]
Add Comment
Please, Sign In to add comment