code_junkie

Computing a 95% confidence interval on the sum of n i.i.d. exponential random variables

Nov 13th, 2011
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. F[x_] := 1 - GammaRegularized[n, a*x];
  2.  
  3. Fi[p_] := InverseGammaRegularized[n, 1 - p]/a;
  4.  
  5. ci[c_, a_, n_] := {Fi[a, n, (1-c)/2], Fi[a, n, c+(1-c)/2]}
  6.  
  7. (* Random draw from an exponential distribution given rate param. *)
  8. getGap[a_] := -1/a*Log[RandomReal[]]
  9.  
  10. betw[x_, {a_, b_}] := Boole[a <= x <= b]
  11.  
  12. c = .95;
  13. a = 1/.75;
  14. n = 40;
  15. ci0 = ci[c, a, n];
  16. N@Mean@Table[betw[Sum[getGap[a], {n}], ci0], {100000}]
  17.  
  18. ----> 0.94995
Add Comment
Please, Sign In to add comment