Docsity

Probability and Statistics Exercises: Solving Problems with R - Prof. Hye-Jeong Yeo, Exercises of Mathematics

Toggle sidebar
bg1
Quoc Hung Pham
ID: 2329423
Question 1
a) > # Define the integrand
> integrand <- function(x) x * (1 - x)
>
> # Compute the integral
> integral <- integrate(integrand, lower = 0, upper = 1)$value
>
> # Solve for k
> k <- 1 / integral
> k
[1] 6
b) > # Define the PDF
> pdf <- function(x) 6 * x * (1 - x)
>
> # Compute the probability
> prob <- integrate(pdf, lower = 0.4, upper = 1)$value
> prob
[1] 0.648
c) > # Define the PDF
> pdf <- function(x) 6 * x * (1 - x)
>
> # Compute P(X < 0.4)
> prob_less_than_0.4 <- integrate(pdf, lower = 0, upper = 0.4)$value
>
> # Compute P(X < 0.8)
> prob_less_than_0.8 <- integrate(pdf, lower = 0, upper = 0.8)$value
>
> # Compute conditional probability
> conditional_prob <- prob_less_than_0.4 / prob_less_than_0.8
> conditional_prob
[1] 0.3928571
d) > # Define the integrand for the mean
> mean_integrand <- function(x) x * 6 * x * (1 - x)
>
> # Compute the mean
> mean_value <- integrate(mean_integrand, lower = 0, upper = 1)$value
> mean_value
[1] 0.5
e) > # Define the integrand for E[X^2]
> E_X_squared_integrand <- function(x) x^2 * 6 * x * (1 - x)
>
> # Compute E[X^2]
> E_X_squared <- integrate(E_X_squared_integrand, lower = 0, upper =
1)$value
>
> # Compute the variance
> variance <- E_X_squared - mean_value^2
> variance
[1] 0.05
f) F(x) = 0, if x < 0
pf3
pf4
pf5

Partial preview of the text

Download Probability and Statistics Exercises: Solving Problems with R - Prof. Hye-Jeong Yeo and more Exercises Mathematics in PDF only on Docsity!

Quoc Hung Pham

ID: 2329423

Question 1

a) > # Define the integrand

> integrand <- function(x) x * (1 - x) > > # Compute the integral > integral <- integrate(integrand, lower = 0, upper = 1)$value > > # Solve for k > k <- 1 / integral > k [1] 6

b) > # Define the PDF

> pdf <- function(x) 6 * x * (1 - x) > > # Compute the probability > prob <- integrate(pdf, lower = 0.4, upper = 1)$value > prob [1] 0.

c) > # Define the PDF

> pdf <- function(x) 6 * x * (1 - x) > > # Compute P(X < 0.4) > prob_less_than_0.4 <- integrate(pdf, lower = 0, upper = 0.4)$value > > # Compute P(X < 0.8) > prob_less_than_0.8 <- integrate(pdf, lower = 0, upper = 0.8)$value > > # Compute conditional probability > conditional_prob <- prob_less_than_0.4 / prob_less_than_0. > conditional_prob [1] 0.

d) > # Define the integrand for the mean

> mean_integrand <- function(x) x * 6 * x * (1 - x) > > # Compute the mean > mean_value <- integrate(mean_integrand, lower = 0, upper = 1)$value > mean_value [1] 0.

e) > # Define the integrand for E[X^2]

> E_X_squared_integrand <- function(x) x^2 * 6 * x * (1 - x) > > # Compute E[X^2] > E_X_squared <- integrate(E_X_squared_integrand, lower = 0, upper = 1)$value > > # Compute the variance > variance <- E_X_squared - mean_value^ > variance [1] 0.

f) F(x) = 0, if x < 0

F(x) = 3x² - 2x³, if 0 ≤ x ≤ 1

F(x) = 1, if x > 1

Question 2

a) > # Define the PDF

> pdf <- function(x) 1 / (x * log(1.5)) > > # Compute the total area > total_area <- integrate(pdf, lower = 4, upper = 6)$value > total_area [1] 1

b) > # Compute the probability

> prob <- integrate(pdf, lower = 4, upper = 5)$value > prob [1] 0.

c) For x < 4: F(x) = 0

For 4 ≤ x ≤ 6: (1/ln (1.5)) * ln (x/4)

For x > 6: F(x) = 1

d) > # Define the integrand for the expected value

> expected_value_integrand <- function(x) x * pdf(x) > > # Compute the expected value > expected_value <- integrate(expected_value_integrand, lower = 4, upper = 6)$value > expected_value [1] 4.

e) > # Define the integrand for E[X^2]

> E_X_squared_integrand <- function(x) x^2 * pdf(x) > > # Compute E[X^2] > E_X_squared <- integrate(E_X_squared_integrand, lower = 4, upper = 6)$value > > # Compute the variance > variance <- E_X_squared - expected_value^ > variance [1] 0.

f) > # Compute the standard deviation

> standard_deviation <- sqrt(variance) > standard_deviation [1] 0.

Question 3

a) > # Define the CDF

> cdf <- function(x) x^2 / 16 > > # Create a sequence of x values > x_values <- seq(0, 4, length.out = 100) > > # Compute the CDF values

  • xlab = "x", ylab = "f(x)", main = "Probability Density Function (PDF)")

e) > # Define the integrand for the expected value

> expected_value_integrand <- function(x) x * pdf(x) > > # Compute the expected value > expected_value <- integrate(expected_value_integrand, lower = 0, upper = 4)$value > expected_value [1] 2.

f) > # Solve for the median

> median <- sqrt(0.5 * 16) > median [1] 2.

Question 4

a) (-2 + 8)/2 = 3

b) (8 + 2) ^2 / 12 = 25/

Sqrt (25/3) = 2.

c) - 2 + 0.8(8 + 2) = 6

d) (3 – 1)/(8 + 2) = 0.

Question 5

a) Z table P(Z < 0.5) = 0.

b) P(Z = 0.5) = 0 (the probability of any exact value is always 0)

c) P(Z ≥ 2.3) = 1 - P(Z < 2.3) = 1 - 0.9893 = 0.

d) P(-1.4 ≤ Z ≤ 0.6) = P(Z ≤ 0.6) - P(Z < - 1.4) = 0.7257 - 0.0808 = 0.

e) P(-z₀ ≤ Z ≤ z₀) = 2P(0 ≤ Z ≤ z₀) = 2[P(Z ≤ z₀) - 0.5]

2[P(Z ≤ z₀) - 0.5] = 0.

P(Z ≤ z₀) = 0.

z₀ ≈ 0.

Question 6

a) Z = (2. 5 - 5)/1 = - 2.

P (X < 2.5) = P (Z < −2.5)

P (Z < −2.5) ≈ 0.0062.

P(X<2.5) = 0.

b) Z = (4.6 - 5)/1 = - 0.

P (X ≥ 4.6) =P (Z ≥ −0.4)

P (Z ≥ −0.4) =1− P (Z < −0.4) = 1 − 0.3446 = 0.

P (X ≥ 4.6) = 0.

c) ∣X∣ ≥ 3 - > X ≤ −3 or X ≥ 3

Z = (3 – 5)/1 = - 2

Z = (- 3 – 5)/1 = - 8

P (X ≤ −3) = P (Z ≤ −8) ≈ 0

P (X ≥ 3) = P (Z ≥ −2) =1− P (Z < −2) = 1− 0.0228 = 0.

P (∣ X ∣≥3) = P ( X ≤−3) + P ( X ≥3) ≈0+0.9772=0.

d) ∣ X −5∣≥3⟹ X ≤2 or X ≥

Z = (2 – 5)/1 = - 3

Z = (8 – 5)/1 = 3

P ( X ≤2)= P ( Z ≤−3)≈0.

P ( X ≥8)= P ( Z ≥3)=1− P ( Z <3) = 1−0.9987=0.

P (∣ X −5∣≥3)= P ( X ≤2)+ P ( X ≥8)≈0.0013+0.0013=0.

Question 7

a) P(X = 104) = 0 (a continuous distribution like the normal distribution)

b) P(X < 104) = 0.5 (since 104 is the mean)

c) P(X ≤ 104) = P(X < 104) = 0.

d) P(X < 99 or X > 109)

P(Z < - 1 or Z > 1) = P(Z < - 1) + P(Z > 1) = P(Z < - 1) + (1 - P(Z < 1))