Mathematica Asked on October 26, 2020
Assuming that the continuous random variables X1
and X2
are independent of each other, and the variances exist, the probability densities of X1
and X2
are $f_{1}(x)$
and $f_{2}(x)$, the probability density of random variable $Y_{1}$ is $f_{Y_{1}}(y)=frac{1}{2}left[f_{1}(y)+f_{2 }(y)right]$, random variablemathrm${Y}_{2}=
frac{1}{2}left(X_{1}+X_{2}right)$. Which of the following statements is correct (the answer is D
)?
$$begin{array}{c}
&(A)& E Y_{1}>E Y_{2}, D Y_{1}>D Y_{2}
&(B)& E Y_{1}=E Y_{2}, D Y_{1}=D Y_{2}
&(C)& E Y_{1}=E Y_{2}, D Y_{1}<D Y_{2}
&(D)& E Y_{1}=E Y_{2}, D Y_{1}>D Y_{2}
end{array}$$
When I use the normal distribution to verify the D
option, the following code keeps running:
Y1 = ProbabilityDistribution[(1/
2) (PDF[NormalDistribution[μ1, σ1], x] +
PDF[NormalDistribution[μ2, σ2], x]), {x, -Infinity,
Infinity}]
Expectation[Y1, Y1 [Distributed] Y1]
Variance[Y1]
Y2 = TransformedDistribution[
1/2 (x1 + x2), {x1 [Distributed]
NormalDistribution[μ1, σ1],
x2 [Distributed] NormalDistribution[μ2, σ2]}]
Expectation[Y2, Y2 [Distributed] Y2]
Variance[Y2]
How can I improve the code to get the desired result?
Clear["Global`*"]
In defining Y1
you need to specify the assumptions needed to make the distribution valid.
Y1 = ProbabilityDistribution[
(1/2) (PDF[NormalDistribution[μ1, σ1], x] +
PDF[NormalDistribution[μ2, σ2], x]),
{x, -Infinity, Infinity},
Assumptions -> {σ1 > 0, σ2 > 0}];
Mean[Y1]
(* (μ1 + μ2)/2 *)
which is equivalent to
Expectation[x, x [Distributed] Y1]
(* (μ1 + μ2)/2 *)
Note that you cannot use the distribution as a variable.
Variance[Y1]
(* 1/4 ((μ1 - μ2)^2 + 2 (σ1^2 + σ2^2)) *)
Y2 = TransformedDistribution[
1/2 (x1 + x2), {x1 [Distributed] NormalDistribution[μ1, σ1],
x2 [Distributed] NormalDistribution[μ2, σ2]}]
(* NormalDistribution[μ1/2 + μ2/2, Sqrt[σ1^2/4 + σ2^2/4]] *)
Mean[Y2] // Simplify
(* (μ1 + μ2)/2 *)
Expectation[x, x [Distributed] Y2]
(* (μ1 + μ2)/2 *)
Variance[Y2] // Simplify
(* 1/4 (σ1^2 + σ2^2) *)
Correct answer by Bob Hanlon on October 26, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP