Question

In: Statistics and Probability

1. Assume Y is an exponential random variable with rate parameter λ=2. (1) Generate 1000 samples...

1. Assume Y is an exponential random variable with rate parameter λ=2.

(1) Generate 1000 samples from this exponential distribution using inverse transform method

(2) Compare the histogram of your samples with the true density of Y.

Please provide MATLAB programming code below with graphs if possible. Thank you!

Solutions

Expert Solution

solution:

Assume;

\(Y\) is an exponential random variable with rate parameter \(\lambda = 2\). Recall that the probability density function is \(p(y) = 2e^{-2y}\), for \(y > 0\). First, we compute the CDF: \[F_Y(x) = P(Y\leq x) = \int_0^x 2e^{-2y} dy = 1 - e^{-2x}\]

Solving for the inverse CDF:

we get that \[F_Y^{-1}(y) = -\frac{\ln(1-y)}{2}\]

Using algorithm;

we first generate \(U \sim \text{Unif}(0,1)\), then set \(X = F_Y^{-1}(U) = -\frac{\ln(1-U)}{2}\).

R code below:

compare the histogram of our samples with the true density of \(Y\).

# inverse transform sampling
num.samples     <-  1000
U               <-  runif(num.samples)
X               <- -log(1-U)/2

# plot
hist(X, freq=F, xlab='X', main='Generating Exponential R.V.')
curve(dexp(x, rate=2) , 0, 3, lwd=2, xlab = "", ylab = "", add = T)

Indeed, the plot indicates that our random variables are following the intended distribution

Past versions of unnamed-chunk-2-1.png

NOTE:  IF you like my answering please rate first . THANK YOU.


Related Solutions

For a random sample of sizenfrom an Exponential distribution with rate parameter λ (so that the...
For a random sample of sizenfrom an Exponential distribution with rate parameter λ (so that the density is fY(y) =λe−λy), derive the maximum likelihood estimator, the methods of moments estimator, and the Bayes estimator (that is, the posterior mean) using a prior proportional to λe−λ, for λ >0. (Hint: the posterior distribution will be a Gamma.)
If Y is a random variable with exponential distribution with mean 1/λ, show that E (Y...
If Y is a random variable with exponential distribution with mean 1/λ, show that E (Y ^ k) = k! / (λ^k), k = 1,2, ...
If X and Y are independent exponential random variables, each having parameter λ  =  6, find...
If X and Y are independent exponential random variables, each having parameter λ  =  6, find the joint density function of U  =  X + Y  and  V  =  e 2X. The required joint density function is of the form fU,V (u, v)  =  { g(u, v) u  >  h(v), v  >  a 0 otherwise (a) Enter the function g(u, v) into the answer box below. (b) Enter the function h(v) into the answer box below. (c) Enter the value...
Let X be an exponential random variable with parameter λ, which means that fX(x) = λe^(−λx)...
Let X be an exponential random variable with parameter λ, which means that fX(x) = λe^(−λx) * u(x). (a) For x > 0, find P(X ≤ x). (b) For x2 > x1 > 0, find P(x1 ≤ X ≤ x2). (c) For x > 0, find P(X ≥ x). (d) Segment the positive real line into three equally likely disjoint intervals.
X and Y are independent Exponential random variables with mean=4, λ = 1/2. 1) Find the...
X and Y are independent Exponential random variables with mean=4, λ = 1/2. 1) Find the joint CDF of the random variables X, Y and  Find the probability that 4X > Y . 2) Find the expected value of X^3 + X*Y .
Suppose X is an exponential random variable with mean 5 and Y is an exponential random...
Suppose X is an exponential random variable with mean 5 and Y is an exponential random variable with mean 10. X and Y are independent. Determine the coefficient of variation of X + Y
Let y1, y2, .....y10 be a random sample from an exponential pdf with unknown parameter λ....
Let y1, y2, .....y10 be a random sample from an exponential pdf with unknown parameter λ. Find the form of the GLRT for H0: λ=λ0 versus H1:λ ≠ λ0. What integral would have to be evaluated to determine the critical value if α were equal to 0.05?
Let X1, X2,..., Xnbe independent and identically distributed exponential random variables with parameter λ . a)...
Let X1, X2,..., Xnbe independent and identically distributed exponential random variables with parameter λ . a) Compute P{max(X1, X2,..., Xn) ≤ x} and find the pdf of Y = max(X1, X2,..., Xn). b) Compute P{min(X1, X2,..., Xn) ≤ x} and find the pdf of Z = min(X1, X2,..., Xn). c) Compute E(Y) and E(Z).
Program in R: Generate 1000 exponential random deviates with the mean equal to ½. Be careful!...
Program in R: Generate 1000 exponential random deviates with the mean equal to ½. Be careful! The exponential is sometimes parameterized directly with the mean, B, using 1/B*exp(-x/B) and sometimes it is parameterized with the rate lambda = 1/B. Know what your software is doing. After generating the data, compute the mean and variance of the data. The mean and variance is all I need to see.
Consider a two-server queue with Exponential arrival rate λ. Suppose servers 1 and 2 have exponential...
Consider a two-server queue with Exponential arrival rate λ. Suppose servers 1 and 2 have exponential rates μ1 and μ2, with μ1 > μ2. If server 1 becomes idle, then the customer being served by server 2 switches to server 1. a) Identify a condition on λ,μ1,μ2 for this system to be stable, i.e., the queue does not grow indefinitely long. b) Under that condition, and the long-run proportion of time that server 2 is busy.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT