Density function of given Interval

71 Views Asked by At

The Density function of a random variable x is given by

f(x) = x^2 + 3x + 2 on the interval [1, 4].

The functions is zero if x > 4 or x < 1

What is the average value of a sample of a million random numbers generated from this function?

1

There are 1 best solutions below

1
On BEST ANSWER

There are a couple conceptual hurdles I will address. In regards to problems involving density functions I have never seen before, one of the first things I will do is first verify that the function given to me is indeed a density function.

By definition, a density function must be nonnegative and integrate to one so we verify this first. Now, $f$ is clearly nonnegative, i.e. $f\geq 0$, everywhere outside the interval $[1,4]$. Further investigation into the function on $[1,4]$ also reveal $f$ satisfies the nonnegativity criteria. Next, we check to see if $f$ integrates to one. Let $\mathbf 1_{A}$ denote the indicator function which, by definition, is one when $A$ is true and zero otherwise. Then, integrating our function $f$ we have $$ M =\int_{-\infty}^\infty f(x)\,\mathrm dx =\int_{-\infty}^\infty (x^2 + 3x + 2) \mathbf 1_{x\in[1,4]}\,\mathrm dx =\int_1^4 (x^2 + 3x + 2)\,\mathrm dx =\frac{99}{2}. $$ So we see that $f$, as given, is not a density function. As such, we will define the density function by normalizing $f$ via $$ g_X(x)=\frac{f(x)}{M}=\frac{2}{99}(x^2 + 3x + 2) \mathbf 1_{x\in[1,4]}. $$ Now that we have a density function our next question is:

What is the average value of a sample of a million random numbers generated from this function?

Using inverse transform sampling I generated one-million observations from $g_X$ and took the mean to get: $\bar x=2.8629$. Generating another million and taking the mean gives: $\bar x=2.86388$. Indeed, if we keep repeating this procedure we will get a different answer every time which is due to the fact that the data generating the averages is random (or at least pseudo-random)! As such, our question cannot be answered.

Now, we can assign an expected value to our density $g_X$ which can loosely be thought of as the "average value" obtained from an infinite number of samples. Using the definition of expected value, if $X\sim g_X$, then $$ \mathsf E X=\int_{-\infty}^\infty xg_X(x)\,\mathrm dx=\int_1^4 x\frac{2}{99}(x^2 + 3x + 2)\,\mathrm dx=63/22=2.86364. $$