Question: Implement a function in MATLAB called sim_exp.m that simulates observations of an exponential random variable. Your function should take as input parameters n and lambda.

Implement a function in MATLAB called sim_exp.m that simulates observations of an exponential random variable. Your function should take as input parameters n and lambda. The output of your function should be a vector of size nx1 containing n samples drawn from an exponential distribution with parameter lambda. You can use the build-in function rand(n,1) in order to generate n uniformly distributed random numbers.

a. Set lambda= 5 and generate a histogram of n = 5000 data points with 20 bins using hist.

Overlay the true exponential pdf with parameter lambda. Comment on the results.

b. Compute the empirical mean and variance of the points you generated. Compare them to the

theoretical mean and variance of an exponential random variable with rate lambda. Comment on the

results.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!