A.4 Exercises
\(x\) | 0 | 1 | 2 | 3 | 4 |
---|---|---|---|---|---|
\(p(x)\) | 0.3 | 0.2 | 0.2 | 0.1 | 0.2 |
- Determine the CDF \(F(x)\) for the random variable, \(X\).
- Create a graphical summary of the CDF. See Example A.4.
- Create the inverse CDF that can be used to determine a sample from the discrete distribution, \(p(x)\). See Example A.4.
- Generate 3 values of \(X\) using the following pseudo-random numbers \(u_1= 0.943, u_2 = 0.398, u_3 = 0.372\)
\(U_1\) | \(U_2\) | \(U_3\) | \(U_4\) | \(U_5\) | \(U_6\) | \(U_7\) | \(U_8\) |
---|---|---|---|---|---|---|---|
0.9396 | 0.1694 | 0.7487 | 0.3830 | 0.5137 | 0.0083 | 0.6028 | 0.8727 |
- Generate an exponentially distributed random number with a mean of 10 using the 1st random number.
- Generate a random variate from a (12, 22) discrete uniform distribution using the 2nd random number.
\(U_1\) | \(U_2\) | \(U_3\) | \(U_4\) | \(U_5\) | \(U_6\) | \(U_7\) | \(U_8\) |
---|---|---|---|---|---|---|---|
0.9559 | 0.5814 | 0.6534 | 0.5548 | 0.5330 | 0.5219 | 0.2839 | 0.3734 |
- Generate a uniformly distributed random number with a minimum of 12 and a maximum of 22 using \(U_8\).
- Generate 1 random variate from an Erlang(\(r=2\), \(\beta=3\)) distribution using \(U_1\) and \(U_2\)
- The demand for magazines on a given day follows the following
probability mass function:
\(x\) | 40 | 50 | 60 | 70 | 80 |
---|---|---|---|---|---|
\(P(X=x)\) | 0.44 | 0.22 | 0.16 | 0.12 | 0.06 |
Using the supplied random numbers for this problem starting at \(U_1\), generate 4 random variates from the probability mass function.
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
\(D\) | 0 | 1 | 2 |
---|---|---|---|
\(p(D)\) | 0.3 | 0.2 | 0.5 |
Generate the demand for the first 4 days using the following sequence of U(0,1) random numbers: 0.943, 0.398, 0.372, 0.943.
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
Exercise A.17 Consider the triangular distribution:
\[F(x) = \begin{cases} 0 & x < a\\ \dfrac{(x - a)^2}{(b - a)(c - a)} & a \leq x \leq c\\ 1 - \dfrac{(b - x)^2}{(b - a)(b - c)} & c < x \leq b\\ 1 & b < x\\ \end{cases}\]- Derive an inverse transform algorithm for this distribution.
- Using 0.943, 0.398, 0.372, 0.943, 0.204 generate 5 random variates from the triangular distribution with \(a = 2\), \(c = 5\), \(b = 10\).
Exercise A.18 Consider the following probability density function:
\[f(x) = \begin{cases} \dfrac{3x^2}{2} & -1 \leq x \leq 1\\ 0 & \text{otherwise} \\ \end{cases}\]- Derive an inverse transform algorithm for this distribution.
- Using 0.943, 0.398 generate two random variates from this distribution.
Exercise A.19 Consider the following probability density function:
\[f(x) = \begin{cases} 0.5x - 1 & 2 \leq x \leq 4\\ 0 & \text{otherwise} \\ \end{cases}\]- Derive an inverse transform algorithm for this distribution.
- Using 0.943, 0.398 generate two random variates from this distribution.
Exercise A.20 Consider the following probability density function:
\[f(x) = \begin{cases} \dfrac{2x}{25} & 0 \leq x \leq 5\\ 0 & \text{otherwise} \\ \end{cases}\]- Derive an inverse transform algorithm for this distribution.
- Using 0.943, 0.398 generate two random variates from this distribution.
Exercise A.21 Consider the following probability density function:
\[f(x) = \begin{cases} \dfrac{2}{x^3} & x > 1\\ 0 & x \leq 1\\ \end{cases}\]- Derive an inverse transform algorithm for this distribution.
- Using 0.943, 0.398 generate two random variates from this distribution.
Exercise A.22 The times to failure for an automated production process have been found to be randomly distributed according to a Rayleigh distribution:
\[\ f(x) = \begin{cases} 2 \beta^{-2} x e^{(-(x/\beta)^2)} & x > 0\\ 0 & \text{otherwise} \end{cases}\]- Derive an inverse transform algorithm for this distribution.
- Using 0.943, 0.398 generate two random variates from this distribution with \(\beta = 2.0\).
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
Exercise A.25 Suppose that the processing time for a job consists of two distributions. There is a 30% chance that the processing time is lognormally distributed with a mean of 20 minutes and a standard deviation of 2 minutes, and a 70% chance that the time is uniformly distributed between 10 and 20 minutes. Using the first row of random numbers the following table generate two job processing times. Hint: \(X \sim LN(\mu, \sigma^2)\) if and only if \(\ln(X) \sim N(\mu, \sigma^2)\). Also, note that:
\[\begin{aligned} E[X] & = e^{\mu + \sigma^{2}/2}\\ Var[X] & = e^{2\mu + \sigma^{2}}\left(e^{\sigma^{2}} - 1\right)\end{aligned}\]
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
Exercise A.29 Prove that the acceptance-rejection method for continuous random variables is valid by showing that for any \(x\),
\[P\lbrace X \leq x \rbrace = \int_{-\infty}^x f(y)dy\]
Hint: Let E be the event that the acceptance occurs and use conditional probability.\[f(x) = \begin{cases} \dfrac{3x^2}{2} & -1 \leq x \leq 1\\ 0 & \text{otherwise} \\ \end{cases}\] a. Derive an acceptance-rejection algorithm for this distribution. b. Using the first row of random numbers from the following table generate 2 random variates using your algorithm.
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
Exercise A.31 This problem is based on (Cheng 1977), see also (Ahrens and Dieter 1972). Consider the gamma distribution:
\[f(x) = \beta^{-\alpha} x^{\alpha-1} \dfrac{e^{-x/\beta}}{\Gamma(\alpha)}\]
where x \(>\) 0 and \(\alpha >\) 0 is the shape parameter and \(\beta >\) 0 is the scale parameter. In the case where \(\alpha\) is a positive integer, the distribution reduces to the Erlang distribution and \(\alpha = 1\) produces the negative exponential distribution.
Acceptance-rejection techniques can be applied to the cases of \(0 < \alpha < 1\) and \(\alpha > 1\). For the case of \(0 < \alpha < 1\) see Ahrens and Dieter (1972). For the case of \(\alpha > 1\), Cheng (1977) proposed the following majorizing function:
\[g(x) = \biggl[\dfrac{4 \alpha^\alpha e^{-\alpha}}{a \Gamma (\alpha)}\biggr] h(x)\]
where \(a = \sqrt{(2 \alpha - 1)}\), \(b = \alpha^a\), and \(h(x)\) is the resulting probability distribution function when converting \(g(x)\) to a density function:
\[h(x) = ab \dfrac{x^{a-1}}{(b + x^a)^2} \ \ \text{for} x > 0\]
Develop an inverse transform algorithm for generating from \(h(x)\)
Using the first two rows of random numbers from the following table, generate two random variates from a gamma distribution with parameters \(\alpha =2\) and \(\beta = 10\) via the acceptance/rejection method.
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
Using the first row of random numbers from the following table generate the first three arrival times.
0.943 | 0.398 | 0.372 | 0.943 | 0.204 | 0.794 |
0.498 | 0.528 | 0.272 | 0.899 | 0.294 | 0.156 |
0.102 | 0.057 | 0.409 | 0.398 | 0.400 | 0.997 |
Exercise A.33 Consider the following function:
\[f(x) = \begin{cases} cx^{2} & a \leq x \leq b\\ 0 & \text{otherwise} \\ \end{cases} \]- Determine the value of \(c\) that will turn \(g(x)\) into a probability density function. The resulting probability density function is called a parabolic distribution.
- Denote the probability density function found in part (a), \(f(x)\). Let \(X\) be a random variable from \(f(x)\). Derive the inverse cumulative distribution function for \(f(x)\).
Exercise A.34 Consider the following probability density function:
\[f(x) = \begin{cases} \frac{3(c - x)^{2}}{c^{3}} & 0 \leq x \leq c\\ 0 & \text{otherwise} \\ \end{cases} \]
Derive an inverse cumulative distribution algorithm for generating from \(f(x)\).