In: Statistics and Probability
Suppose that the distribution of wind velocity, X, is described by the probability density function f(x) = (x/σ^2)e^-(x^2/ 2(σ^2)) , x ≥ 0. Suppose that for the distribution of wind velocity in Newcastle, measured in km/hr, σ^2 = 100.
(a) In task 1, you showed that the quantile function for this distribution is given by: Q(p) = σ (−2 ln(1 − p))^(1/2), 0 ≤ p < 1 Use this quantile function to generate 100,000 random values from this distribution (when σ 2 = 100) in R using the probability integral transformation, as follows:
• Generate 100,000 random values Y from a Uniform distribution from 0 to 1
• Generate 100,000 random values from X using its quantile function: X = Q(Y ).
(b) In task 1, you showed that the median of X is 11.77 km/hr. Verify this by finding the median of the 100,000 random numbers generated from X in part (a).
(c) In task 1, you showed that the expected value of X is σ (π 2) . When σ^2 = 100, E(X) = 12.53 km/hr. Verify this by finding the mean of the 100,000 random numbers generated from X in part (a). To earn full marks, provide all R commands used to calculate the mean and evidence of your numerical estimate (screenshot or RMarkdown).
(d) Consider the transformation W = (X^2)/ (2(σ^2)) Show that W is a monotonically increasing function of X.
(e) Use either the change-of-variable method or the distribution function method to show that W follows an exponential distribution with λ = 1.
(f) Use R to generate 100,000 values of W by applying the transformation from part (d) to the 100,000 values of X generated in part (a). To earn full marks, provide all R commands used (screenshot or RMarkdown).
(g) As W follows an exponential distribution with λ = 1, both the expected value and variance of W are equal to 1. Verify this by deriving the mean and variance of the 100,000 values generated from W. To earn full marks, provide all R commands used to calculate the mean and variance and evidence of your numerical estimates (screenshot or RMarkdown).
The pdf of wind velocity, X is given by
In task1 I think you have already shown that the cdf of X is
Using this we have the quantile function as
We will use R to do the following steps
R-Code
#set the seed
set.seed(123)
#set the value of sigma
sigma<-sqrt(100)
#Generate 100,000 random values Y from a Uniform distribution from
0 to 1
n<-100000
Y<-runif(n,0,1)
#Generate 100,000 random values from X using its quantile function:
X = Q(Y ).
X<-sigma*sqrt(-2*log(1-Y))
#print some values of X
head(X)
#--output is
b) R code for median of X
#b)median of X
Xmedian<-median(X)
print(paste("Median of X is",round(Xmedian,2)))
#--output is
Sample median is close to the theoretical value of 11.77
c) Expected value of X
#c) Expected value of X
Xmean<-mean(X)
print(paste("Sample mean of X is",round(Xmean,2)))
#--output is
Sample mean of 12.52 is close to the expected value of 12.53
d) The transformation is
A function is monotonically increasing if its first derivative is positive over the domain of the function
The first derivative of W is
We know that the . That means the first derivative is also positive for the entire range of X.
Hence W is a monotonically increasing function of X
e) First we will state the general theorem of transformation
If X has a pdf and the transformation W=g(x) is monotonically increasing
the pdf of W is
Here
and
the pdf of W is
This is an exponential distribution with
f) Use R to generate 100,000 values of W
R code
#f) Use R to generate 100,000 values of W
W<-X^2/(2*sigma^2)
#print some values of W
head(W)
#--output is below
g) R code
#g) mean and variance of the 100,000 values generated from
W
Wmean<-mean(W)
print(paste("Sample mean of W is",round(Wmean,2)))
Wvar<-var(W)
print(paste("Sample variance of W is",round(Wvar,2)))
#--output is
Mean and variance are equal to 1, as expected