Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1467
Number of posts: 2144

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Law of Large numbers of exponential random variables Posted by lalpal123 on 5 Apr 2011 at 1:15 AM
The moment generating function of an exponential random variable X is given by mgf(t) = m/(m - t)

That is, mgf(t) = E(exp(t*X)) = m/(m - t)

Let X_1, X_2, .... X_n are iid random variables having exponential distribution with parameter m.

Let m = 2;

and t = 0.5;

n = 10000

I wish to get an estimate of mgf(0.5) using sum_{i = 1 to 10000} exp(0.5 * X_i) as given my code below:

size = 10000;

m = 2;

xVal = exprnd(m,[1,size]);

t = 0.5;

tVal = t * xVal;

eVal = exp(tVal);

avgVal = sum(eVal)/size

actVal = m/(m - t)

the actual value is 4/3 = 1.333 given by actVal

When I run my code the estimate avgVal churns out results such as
9.9936, 12.9107, 10.6934

when it should ideally give values close to 1.333 according to the law of large numbers.

I face similar problems for quite a few values of m and t.

Where am I going wrong??
Report
Re: Law of Large numbers of exponential random variables Posted by sambo8 on 8 May 2011 at 9:22 PM
Yes, but the value you must to generate the exponential should be 1/m instead of m. The population mean of an exponential distribution with parameter m is 1/m. In the matlab exprnd(mu,...) function, mu is supposed to be the mean. When you factor this, you get it right.
Hope it was clear.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.