Grando 5 Discussion

Chapter 2.2 Exercise 2

Suppose you choose a real number X from the interval [2, 10] with a density function of the form

\[f\left( x \right)=Cx\]

where C is a constant.

(a) Find C.

Answer:

To find this, we can simply integrate the distribution function to get the cumulative distribution function.

\[\int _{ 2 }^{ 10 }{ Cxdx } = { \left[ \frac { C{ x }^{ 2 } }{ 2 } \right] }_{ 2 }^{ 10 }=1\]

And then we can sovle for C:

\[1=\frac { C \times { 10 }^{ 2 } }{ 2 } - \frac { C \times { 2 }^{ 2 } }{ 2 }=\frac{ C \times \left( {10}^{2}-{2}^{2} \right)}{2}\]

\[C = \frac { 1\times 2 }{ \left( { 10 }^{ 2 }-{ 2 }^{ 2 } \right) } = \frac{2}{96}\]

library(ggplot2)
C <- 2/96
(C * 10^2/2 - C * 2^2/2)
## [1] 1
d5_function <- function(c, x, y) {
    return(c * y^2/2 - c * x^2/2)
}
d5_function(C, 2, 10)
## [1] 1
ggplot(data.frame(x = c(2, 10)), aes(x)) + stat_function(fun = function(x) C * 
    x, geom = "line") + ggtitle(label = "Distribution Function") + 
    theme(plot.title = element_text(size = 14, color = "grey55", 
        hjust = 0.5))

ggplot(data.frame(x = c(2, 10)), aes(x)) + stat_function(fun = function(x) C * 
    x^2/2 - (C * 10^2/2 - 1), geom = "line") + ggtitle(label = "Cumulative Distribution Function") + 
    theme(plot.title = element_text(size = 14, color = "grey55", 
        hjust = 0.5))

(b) Find P(E), where E = [a, b] is a subinterval of [2, 10].

Answer:

P(E) is just the area under the curve of the distribution function, or more simply, the difference between the two values from the integrated function (cumulative distribution function):

\[P\left( E \right) ={ \left[ \frac { C{ x }^{ 2 } }{ 2 } \right] }_{ a }^{ b }=\frac { C\times { b }^{ 2 } }{ 2 } -\frac { C\times { a }^{ 2 } }{ 2 } \]

(c) Find P(X > 5), P(X < 7), and P(X 2 − 12X + 35 > 0).

Answer:

For P(X > 5):

d5_function(C, 5, 10)
## [1] 0.78125

For P(X < 7):

d5_function(C, 2, 7)
## [1] 0.46875

For \(P\left({X}^{2} − 12X + 35 > 0 \right)\), this will require some additional algebra:

First, we need to find the soultion range for this equation where the result is greater than zero:

a = 1
b = -12
c = 35

x_1 = (-b + sqrt(b^2 - 4 * a * c))/(2 * a)
x_2 = (-b - sqrt(b^2 - 4 * a * c))/(2 * a)
ggplot(data.frame(x = c(2, 10)), aes(x)) + stat_function(fun = function(x) x^2 - 
    12 * x + 35, geom = "line") + geom_vline(xintercept = x_1, 
    color = "grey") + geom_text(aes(x = x_1 - 0.2, y = 5, label = paste("intercept at x =", 
    x_1, sep = " ")), angle = 90) + geom_vline(xintercept = x_2, 
    color = "grey") + geom_text(aes(x = x_2 - 0.2, y = 5, label = paste("intercept at x =", 
    x_2, sep = " ")), angle = 90)

So, we can see that we need to compute the Probability of \(P([2,5]\cap[7,10])\)

d5_function(C, 2, 5) + d5_function(C, 7, 10)
## [1] 0.75