Simulation Using Pseudorandom Numbers and the Inversion Method

108 Views Asked by At

I am trying to do this problem to understand the statistics Could you please help me out?

Consider the distribution function of the so-called extreme value distribution with parameters a and b:

enter image description here Implement a matlab function myev(a,b) that returns a single pseudorandom number for this distribution on each call using the inversion method. Put down the mathematical considerations below on this printout.

b) Implement a simulation of the following scenario: values of myev(10,2) are used to draw samples of the monthly maximum level of water in a hydropower station. If out of the 12 values describing a year’s monthly maximum levels, at least 6 are smaller than the yearly mean value, this year is a “bad=0” one, otherwise, it is a “good=1” year. Implement a function simu() that simulates one year and classifies it and outputs either 1 or 0. c) Implement a script control() that outputs the percentage of “good” years. To do so, compute (below) a sample size n of simulations such that the 95% confidence interval for this estimate is ±5%.

1

There are 1 best solutions below

2
On BEST ANSWER

Hint about the theory (ignoring particulars of Matlab): My intent is to review and illustrate the 'inversion' method without doing your Matlab homework.

Let $U = F(X) = \exp[-\exp(-\frac{X-a}{b})],$ and solve for $X$ in terms of $U$ to obtain $X = F^{-1}(U).$ Then if $U \sim \mathsf{UNIF}(0,1),$ the corresponding $X$ is a random observation from the distribution described by the CDF $F.$

As a closely-related example, you can use a random number generator that produces standard uniform output $U$ to get realizations of $X \sim \mathsf{Exp}(1),$ which has CDF $F(x) = 1 - e^{-x},$ for $x > 0.$ Setting $U = F(X)$ gives $X = -\ln(1-U).$ [This is often simplified to $X = -\ln U$ because both $U$ and $1-U$ are both standard uniform.]

In R statistical software, the following code simulates an $m$-vector of independent realizations of $\mathsf{Exp}(1).$ [The function runif, without extra arguments, generates the indicated number of standard uniform RVs. log is $\ln,$ and dexp is the exponential density function, where the second argument is the rate parameter.]

m = 10^6;  u = runif(m);  x = -log(1 - u)
hist(x, prob=T, col="skyblue2", 
    main="Histogram of Simulated Dist'n of EXP(1) with Exact PDF")
curve(dexp(x, 1), lwd=2, col="red", add=T)

enter image description here