Generate random sample size 100 from the distribution with density f(x) = 2 exp(−2x), x ≥ 0. Check the feasibility of the obtained data using: histogram, mean, variance, EDF.
R code:
y=runif(100,0,1)
x=-0.5*log(1-y)
hist(x,breaks=5)
mean(x)
var(x)
z=ecdf(x)
plot(z, xlab = 'Sample Quantiles of x', ylab = '', main =
'Empirical Cumluative Distribution of x')
mtext(text = expression(hat(F)[n](x)), side = 2, line = 2.5)
Out put:
> mean(x)
[1] 0.4322894
> var(x)
[1] 0.1811383
Get Answers For Free
Most questions answered within 1 hours.