In: Math
Let X be a random variable with CDF F(x) = e-e(µ-x)/β, where β > 0 and -∞ < µ, x < ∞.
1. What is the median of X?
2. Obtain the PDF of X. Use R to plot, in the range -10<x<30, the pdf for µ = 2, β = 5.
3. Draw a random sample of size 1000 from f(x) for µ = 2, β = 5 and draw a histogram of the values in the random sample drawn. Compare this histogram with the answer in 2 above.
Following is the R Code to draw probability plot
rm(list=ls(all=T))
mu <- 2;
beta <- 5;
x <- seq(-10,30,by=0.01)
pdf <- (1/beta)*exp((mu-x)/beta)*exp(-exp((mu-x)/beta));
plot(x,pdf,type="l",main="Figure 1")
Following is the code to plot histogram and comparing it with probability plot
rm(list=ls(all=T))
mu <- 2;
beta <- 5;
x <- seq(-10,30,by=0.01)
pdf <- (1/beta)*exp((mu-x)/beta)*exp(-exp((mu-x)/beta));
xs <- mu-beta*log(-log(runif(1000)));
hist(xs, main="Figure 2", probability=T)
plot(x,pdf,type="l")
From the graph, it is observed that both the probability density plot and histogram are matching to each other