Let (X) be a continuous random variable denoting the time between the product being sold out and placed back on the shelf. The probability density function (PDF) of (X) is given by:
[ p_(x) = \[\begin{cases} e^{-\lambda (x-b)}, & x \geq b \\ 0, & x < b \end{cases}\]]
We need to determine the value of (a). To do this, we use the normalization condition for the probability density function, which states that the total probability must equal 1:
[ {-}^p(x) , dx = 1 ]
Since the PDF is 0 for (x < b), the limits of integration are adjusted to (b) to ():
[ _b^a e^{-(x-b)} , dx = 1 ]
Factor out (-b) from the exponent:
[ _b^a e^{-x} e^{b} , dx = 1 ]
This can be rewritten as:
[ a e^{b} _be{-x} , dx = 1 ]
The integral of the exponential function (e^{-x}) is well known. Adjusting the limits:
[ _be{-x} , dx = ]
Substitute this result back:
[ a e^{b} = 1 ]
The terms (e^{b}) and (e^{-b}) cancel out:
[ a = 1 ]
Multiply through by ():
[ a = ]
Thus, the value of (a) is:
[ a = ]
Let ( p_(x) ) be the PDF of a shifted exponential distribution:
\[ p_\lambda(x) = \begin{cases} \lambda e^{-\lambda (x - b)} & \text{if } x \geq b, \\ 0 & \text{if } x < b. \end{cases} \]
The population mean ( _X ) is given by:
\[ \mu_X = \mathbb{E}[X] = \int_{-\infty}^\infty x \cdot p_\lambda(x) \, dx \]
Since ( p_(x) = 0 ) for ( x < b ), the integration limits reduce to ( [b, ) ):
\[ \mu_X = \int_b^\infty x \cdot \lambda e^{-\lambda (x - b)} \, dx \]
Simplify ( -(x - b) ) as ( -x + b ):
\[ \mu_X = \int_b^\infty x \cdot \lambda e^{\lambda b} e^{-\lambda x} \, dx \]
Factor out constants ( e^{b} ):
\[ \mu_X = \lambda e^{\lambda b} \int_b^\infty x e^{-\lambda x} \, dx \]
Perform a substitution: let ( u = x - b ), so ( x = u + b ) and ( dx = du ). The integration limits change to ( u = 0 ) and ( u ):
\[ \mu_X = \lambda e^{\lambda b} \int_0^\infty (u + b) e^{-\lambda (u + b)} \, du \]
Expand the terms ( u + b ) in the integral:
\[ \mu_X = \lambda e^{\lambda b} \left( \int_0^\infty u e^{-\lambda u} e^{-\lambda b} \, du + \int_0^\infty b e^{-\lambda u} e^{-\lambda b} \, du \right) \]
Combine ( e^{-b} ):
\[ \mu_X = \lambda \left( \int_0^\infty u e^{-\lambda u} \, du + b \int_0^\infty e^{-\lambda u} \, du \right) \]
Using the formula for the expected value of ( X ) for an exponential distribution: [ _0^u e^{-u} , du = ]
Using the exponential integral: [ _0e{-u} , du = ]
Substitute these results into the expression for ( _X ):
\[ \mu_X = \lambda \left( \frac{1}{\lambda^2} + b \cdot \frac{1}{\lambda} \right) \]
Simplify:
\[ \mu_X = \frac{1}{\lambda} + b \]
Thus, the mean is:
\[ \mu_X = b + \frac{1}{\lambda} \]
The variance is given by:
\[ \sigma_X^2 = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 \]
The second moment is:
\[ \mathbb{E}[X^2] = \int_{-\infty}^\infty x^2 \cdot p_\lambda(x) \, dx \]
Again, limits reduce to ( [b, ) ):
\[ \mathbb{E}[X^2] = \int_b^\infty x^2 \cdot \lambda e^{-\lambda (x - b)} \, dx \]
Substitute ( u = x - b ), ( x = u + b ), and ( dx = du ):
\[ \mathbb{E}[X^2] = \lambda e^{\lambda b} \int_0^\infty (u + b)^2 e^{-\lambda (u + b)} \, du \]
Expand ( (u + b)^2 ):
\[ \mathbb{E}[X^2] = \lambda e^{\lambda b} \int_0^\infty \left( u^2 + 2ub + b^2 \right) e^{-\lambda (u + b)} \, du \]
Distribute the terms:
\[ \mathbb{E}[X^2] = \lambda \left( \int_0^\infty u^2 e^{-\lambda u} \, du + 2b \int_0^\infty u e^{-\lambda u} \, du + b^2 \int_0^\infty e^{-\lambda u} \, du \right) \]
Using the formula for the second moment of ( X ) in an exponential distribution: [ _0u2 e^{-u} , du = ]
Substitute these results:
\[ \mathbb{E}[X^2] = \lambda \left( \frac{2}{\lambda^3} + 2b \cdot \frac{1}{\lambda^2} + b^2 \cdot \frac{1}{\lambda} \right) \]
Simplify:
\[ \mathbb{E}[X^2] = \frac{2}{\lambda^2} + \frac{2b}{\lambda} + b^2 \]
Substitute ( [X^2] ) and ( ([X])^2 ) into the variance formula:
\[ \sigma_X^2 = \mathbb{E}[X^2] - (\mathbb{E}[X])^2 \]
We know:
[ [X] = b + , ([X])^2 = ( b + )^2 ]
Substitute and simplify:
\[ \sigma_X^2 = \frac{2}{\lambda^2} + \frac{2b}{\lambda} + b^2 - \left( b^2 + \frac{2b}{\lambda} + \frac{1}{\lambda^2} \right) \]
Cancel terms:
\[ \sigma_X^2 = \frac{1}{\lambda^2} \]
Thus, the variance is:
\[ \sigma_X^2 = \frac{1}{\lambda^2} \]
We are given ( X_1, X_2, , X_n ), independent samples from an exponential distribution with a rate parameter ( > 0 ) and a location parameter ( b ). The probability density function (PDF) is:
[ p_(x) = \[\begin{cases} \lambda e^{-\lambda (x - b)} & \text{if } x \geq b, \\ 0 & \text{if } x < b. \end{cases}\]]
Our goal is to derive the Maximum Likelihood Estimate (MLE) for ( ), and compute it using R for a given dataset.
The likelihood function is the joint probability of observing ( X_1, X_2, , X_n ), given ( ):
[ L() = {i=1}^n p(X_i). ]
Substituting the PDF:
[ L() = _{i=1}^n e^{-(X_i - b)} . ]
Simplify the product:
[ L() = ^n e^{-_{i=1}^n (X_i - b)}. ]
Taking the natural logarithm of the likelihood function:
[ () = L() = (^n) + (e^{-_{i=1}^n (X_i - b)}). ]
Using logarithmic properties:
[ () = n () - _{i=1}^n (X_i - b). ]
To maximize ( () ), we take its derivative with respect to ( ):
[ = ( n () - _{i=1}^n (X_i - b) ). ]
Differentiating term by term:
Thus:
[ = - _{i=1}^n (X_i - b). ]
Setting ( = 0 ):
[ = _{i=1}^n (X_i - b). ]
Rearranging:
[ = . ]
Thus, the MLE for ( ) is:
[ = . ]
question 5 : We aim to calculate the Maximum Likelihood Estimate (MLE) of ( ) for the given dataset. The formula is:
[ _{} = , ]
where:
The following R code calculates ( _{} ): {r} # Load the dataset supermarket_df <- data.frame(read.csv(“supermarket_data_2024(1).csv”))
b <- 300
n <- length(supermarket_df\(TimeLength) # Number of observations sum_x <- sum(supermarket_df\)TimeLength - b) # Sum of adjusted observations
lambda_MLE <- n / sum_x
lambda_MLE
{r}
set.seed(123) # For reproducibility B <- 10000 # Number of bootstrap resamples
bootstrap_lambdas <- replicate(B, { bootstrap_sample <- sample(supermarket_df$TimeLength, size = n, replace = TRUE) sum_x <- sum(bootstrap_sample - b) n / sum_x # Lambda MLE for the bootstrap sample })
ci <- quantile(bootstrap_lambdas, c(0.025, 0.975))
cat(“95% Bootstrap Confidence Interval for lambda:”) cat(sprintf(“Lower Bound: %.4f, Upper Bound: %.4f”, ci[1], ci[2]))