Question

In: Statistics and Probability

R Code 2. Suppose X is a random variable with density f(x; ψ) = 2ψ-2 xI(0...

R Code

2. Suppose X is a random variable with density f(x; ψ) = 2ψ-2 xI(0 ≤ x ≤ ψ), where ψ > 0 is a parameter.

(a) Draw a graph of the density when ψ = 3 in R.

(b) Write a function called genTri that generates n independent realizations of X. The function should take the arguments n and psi and return a vector of n realizations. Make a histogram of n = 104 realizations and compare the histogram to the density plot in the previous question.

(c) Derive an expression for E(X) – it will be a function of ψ. Confirm your expression when ψ = 3 using a Monte Carlo simulation.

(d) A 95% confidence interval for E(X) is given by Xbar ± t0.975,n−1 * S/√ n, where Xbar is the sample mean of n independent copies of X and t0.975,n−1 denotes the 97.5th percentile of the t-distribution with n − 1 degrees of freedom. For n = 5, 10, 15, 100 and ψ = 3, estimate the probability P(Xbar − t0.975,n−1 * S/√ n ≤ ψ ≤ Xbar + t0.975,n−1 * S/√ n) using a Monte Carlo simulation with 104 replications. Note: you can use the qt function in R to generate the respective t percentiles.

Solutions

Expert Solution

The pdf of the random variable is

a) For , the graph of the pdf is plotted below using R.

curve(2*x/9, ylab = "f(x)", xlim = c(0,3), col="darkred", lwd=2)

b) Using Invesre transform method, we can generate random variables from the above distribution.

If is standard uniform RV, then is RV from .

The R code (with function genTri) to generate 104 realizations of the RV and plot the histogram is given below.

n_random = 104
psi <- 3
genTri <- function(n, psi)
{
U <- runif(n)
X <- sqrt(U)*psi
return(X)
}
X <- genTri(n_random, psi)
hist(X, prob = TRUE,freq = FALSE, col = "skyblue", xlab = "x", main = "Histogram")

The histogram has increasing steps.

c) The expected value of the RV is

When , theoretical mean is and the simulated mean is .

Codee below.

n_random = 104
psi <- 3
genTri <- function(n, psi)
{
U <- runif(n)
X <- sqrt(U)*psi
return(X)
}
X <- genTri(n_random, psi)
mean(X)

d) The R code for finding the probability

where is given below.

nsims = 104
n <- 100
psi <- 3
n_total <- 0
genTri <- function(n, psi)
{
U <- runif(n)
X <- sqrt(U)*psi
return(X)
}
for(i in 1:nsims)
{
X <- genTri(n, psi)
xbar <- mean(X)
s <- sd(X)
t <- qt(0.975,n-1)
if (xbar - t*s/sqrt(n) < 2*psi/3 & xbar + t*s/sqrt(n) > 2*psi/3 )
{
n_total <- n_total + 1
}
  
}

n_total/nsims

The probability for

is

is

is

is


Related Solutions

A continuous random variable X, has the density function f(x) =((6/5)(x^2)) , 0 ≤ x ≤...
A continuous random variable X, has the density function f(x) =((6/5)(x^2)) , 0 ≤ x ≤ 1; (6/5) (2 − x), 1 ≤ x ≤ 2; 0, elsewhere. (a) Verify f(x) is a valid density function. (b) Find P(X > 3 2 ), P(−1 ≤ X ≤ 1). (c) Compute the cumulative distribution function F(x) of X. (d) Compute E(3X − 1), E(X2 + 1) and σX.
The random variable X has a continuous distribution with density f, where f(x) ={x/2−5i f10≤x≤12 ,0...
The random variable X has a continuous distribution with density f, where f(x) ={x/2−5i f10≤x≤12 ,0 otherwise. (a) Determine the cumulative distribution function of X.(1p) (b) Calculate the mean of X.(1p) (c) Calculate the mode of X(point where density attains its maximum) (d) Calculate the median of X, i.e. a number m such that P(X≤m) = 1/2 (e) Calculate the mean of the random variable Y= 12−X (f) Calculate P(X^2<121)
The following density function describes a random variable X. f(x)= (x/64) if 0<x<8 and f(x) =...
The following density function describes a random variable X. f(x)= (x/64) if 0<x<8 and f(x) = (16-x)/64 if 8<x<16 A. Find the probability that X lies between 2 and 6. B. Find the probability that X lies between 5 and 12. C. Find the probability that X is less than 11. D. Find the probability that X is greater than 4.
1. The random variable X has probability density function: f(x) = ( ke−x 0 ≤ x...
1. The random variable X has probability density function: f(x) = ( ke−x 0 ≤ x ≤ ln 5 4 0 otherwise Part a: Determine the value of k. Part b: Find F(x), the cumulative distribution function of X. Part c: Find E[X]. Part d: Find the variance and standard deviation of X. All work must be shown for this question. R-Studio should not be used.
The random variable X has probability density function: f(x) = ke^(−x) 0 ≤ x ≤ ln...
The random variable X has probability density function: f(x) = ke^(−x) 0 ≤ x ≤ ln (5/4) 0 otherwise Part a: Determine the value of k. Part b: Find F(x), the cumulative distribution function of X. Part c: Find E[X]. Part d: Find the variance and standard deviation of X. All work must be shown for this question.
1. Let X be random variable with density p(x) = x/2 for 0 < x<...
1. Let X be random variable with density p(x) = x/2 for 0 < x < 2 and 0 otherwise. Let Y = X^2−2. a) Compute the CDF and pdf of Y. b) Compute P(Y >0 | X ≤ 1.8).
A probability density function on R is a function f :R -> R satisfying (i) f(x)≥0...
A probability density function on R is a function f :R -> R satisfying (i) f(x)≥0 or all x e R and (ii) \int_(-\infty )^(\infty ) f(x)dx = 1. For which value(s) of k e R is the function f(x)= e^(-x^(2))\root(3)(k^(5)) a probability density function? Explain.
Prove (a) that ψ ± = N (x ± iy)f(r) is an eigenfunction of L^2 and...
Prove (a) that ψ ± = N (x ± iy)f(r) is an eigenfunction of L^2 and Lz and set the eigenvalues corresponding. (b) Construct a wave function ψ_0(r) that is an eigenfunction of L^2 whose eigenvalue is the same as that of a), but whose eigenvalue Lz differs by a unit of the one found in a). (c) Find an eigenfunction of L^2 and Lx, analogous to those of parts a) and b), which have the same eigenvalue L^2 but...
2 Consider the probability density function (p.d.f) of a continuous random variable X: f(x) = (...
2 Consider the probability density function (p.d.f) of a continuous random variable X: f(x) = ( k x3 , 0 < x < 1, 0, elsewhere, where k is a constant. (a) Find k. (b) Compute the cumulative distribution function F(x) of X. (c) Evaluate P(0.1 < X < 0.8). (d) Compute µX = E(X) and σX.
A random variable X has a density given by f X ( x ) = (1...
A random variable X has a density given by f X ( x ) = (1 − x^2 ) [ u ( x ) − u ( x − 1) ] + aδ ( x − 2 )where u(x) is the unit step function and δ(x) is a delta function. a). Find the value of a, E(X) and σ δx^2 . b). Find and make a labeled sketch of FX (x) . C). W = the event {X ≥ 0.5}....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT