Question

In: Statistics and Probability

Use the Rejection Method to generate n = 1000 values for a random variable X distributed...

Use the Rejection Method to generate n = 1000 values for a random variable X distributed as Exponential (lambda=5). Create a density histogram for your generated values and superimpose the probability density function of the target distribution to the histogram. Use the generated values to estimate the mean, standard deviation, and the probability that X < 2. Compare them with the theoretic values which are 0.2, 0.2, and 0.97725, respectively. Report the rejection rate. Write in R code

Solutions

Expert Solution

We have to generate random variable from distribution with density

Acceptance-Rejection Algorithm for continuous random variables

1. Generate a RV distributed as .

2. Generate (independent from )

3. If , then set ; otherwise go back to 1, (“reject”).

Take . Then
To find the maximum value of , . We can write,

.Thus,

The R code generate 10000 samples from distribution using rejection method and plotting the histogram and superimpose the probability density function of the target distribution to the histogram is given below:

N <- 1000
c <- 5
n <- 1
X <- array(dim = N)
g<- function (x)
{
exp(-x)
}
f<- function (x)
{
5*exp(-5*x)
}
while(n<=N)
{
Y <- rexp(1,1)
U <- runif(1)
if(U < f(Y)/g(Y)/c)
{
X[n] <- Y
n <- n+1
}
}
plot(1:1)
dev.new()
hist(X,prob = TRUE, col = "skyblue", main = "Histogram of Exponential Distribution")
curve(dexp(x,5),add=TRUE,lwd=2,col="blue")
mean(X)
sd(X)
length(X[X<2])/N

The simulated mean is 0.1917748,  standard deviation is 0.1816255, and the probability .

The rejection rate is proportional to .


Related Solutions

Use Excel to generate 100 N (10,5) distributed random values (that is 100 values of a...
Use Excel to generate 100 N (10,5) distributed random values (that is 100 values of a Normally distributed random variable with mean 10 and standard deviation 5). Plot histogram for your data. See Appendix on how to generate these values.
Use R to generate n = 400 samples (idependent identically distributed random numbers) of X ∼...
Use R to generate n = 400 samples (idependent identically distributed random numbers) of X ∼ N(0, 4). For each Xi , simulate Yi according to Yi = 3 + 2.5Xi + εi , where εi ∼ N(0, 16), i = 1, ..., n. Use R to solve the following questions. (a) Compute the least square estimators of βˆ 0 and βˆ 1. (b) Draw a regression line according to the numbers computed in (a). Plot Y and X with...
Data set : Data Set G: Assume the population values are normally distributed. Random variable: x...
Data set : Data Set G: Assume the population values are normally distributed. Random variable: x = weight of border collie in pounds sample size = 25 34.1 40.8 36.0 34.9 35.6 43.4 35.4 29.3 33.3 37.8 35.8 37.4 39.0 38.6 33.9 36.5 37.2 37.6 37.3 37.7 34.9 33.2 36.2 33.5 36.9 1. Choose another confidence level similar to one found in the homework (do not use the confidence level from the posted example). Based on the second confidence level,...
X is a random variable for losses. X follows a beta distribution with θ = 1000,...
X is a random variable for losses. X follows a beta distribution with θ = 1000, a = 2, and b = 1. Calculate TVaR0.90(X)
The random variable X can take on the values 1, 2 and 3 and the random...
The random variable X can take on the values 1, 2 and 3 and the random variable Y can take on the values 1, 3, and 4. The joint probability distribution of X and Y is given in the following table: Y 1 3 4 X 1 0.1 0.15 0.1 2 0.1 0.1 0.1 3 0.1 0.2 a. What value should go in the blank cell? b. Describe in words and notation the event that has probability 0.2 in the...
The random variable X can take on the values -5, 0, and 5, and the random...
The random variable X can take on the values -5, 0, and 5, and the random variable Y can take on the values 20, 25, and 30. The joint probability distribution of X and Y is given in the following table: Y 20 25 30 X -5 0.15 0.02 0.06 0 0.08 0.05 0.05 5 0.32 0.10 0.17 a. Describe in words and notation the event that has probability 0.17 in the table. . b. Calculate the marginal distribution of...
X is a random variable which is normally distributed with a mean of 99.01 and a...
X is a random variable which is normally distributed with a mean of 99.01 and a standard deviation of 15.56. Use the Excel function NORMINV to determine the required value of Xo to two decimal places. Give your answer in the form xx.xx. P(X < Xo) = 0.0344 Answer:
Assume that x is a binominal random variable with n=100 and p=0.40. Use a normal approximation...
Assume that x is a binominal random variable with n=100 and p=0.40. Use a normal approximation to find the following: a) P(x≥38) b) P(x=45) c) P(x>45) d) P(x<45)
Required information Suppose X is a binomial random variable with n = 25 and p=.7. Use...
Required information Suppose X is a binomial random variable with n = 25 and p=.7. Use the Binomial table to find the following: a. P(X=18) b. P(X=15) c. P(X≤20) d. P(X≥16)
1. (Use Computer) Let X represent a binomial random variable with n = 400 and p...
1. (Use Computer) Let X represent a binomial random variable with n = 400 and p = 0.8. Find the following probabilities. (Round your final answers to 4 decimal places.)   Probability   a. P(X ≤ 330)         b. P(X > 340)         c. P(335 ≤ X ≤ 345)         d. P(X = 300)       2. (Use computer) Suppose 38% of recent college graduates plan on pursuing a graduate degree. Twenty three recent college graduates are randomly selected. a. What is the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT