计算期望和方差

  • 给定概率密度函数f(x), 用Integrate[f(x)*x, {x, 0, Infinity}]计算期望, 用二阶矩Integrate[f(x)*x^2, {x, 0, Infinity}]减去期望的平方计算方差.
  • 给定概率分布dist, 用Mean[dist]计算分布dist的期望, 用Variance[dist]计算分布dist的方差.

  1. $$ X \verb|~| f(x)=\left\{ \begin{matrix} \frac{1}{9}x{{e}^{-\frac{x}{3}}}, & x>0 \\ 0, & 其它 \\ \end{matrix} \right. $$, 求$E(X),D(X)$.

输入如下

EX=Integrate[x^2/9*Exp[-x/3],{x,0,Infinity}]
E2=Integrate[x^3/9*Exp[-x/3],{x,0,Infinity}]  
DX=E2-EX^2

得到结果$E(X)=6, D(X)=18$.

  1. $X \sim N\left(\mu, \sigma^2\right)$, 求 $E(X), D(X)$
Mean[NormalDistribution[μ,σ]]    
Variance[NormalDistribution[μ,σ]]

输出结果为:
$μ, σ^2$

求区间估计

  • 计算均值的置信水平为95%的置信区间用 MeanCI[list]
  • 计算方差的置信水平为95%的置信区间用 VarianceCI[list]

  1. 55.96,56.54,57.58,55.13,57.48,56.06,59.93,58.30,52.57,58.46,已知方差为4, 求μ的置信水平为0.95的置信区间
<<Statistics\ConfidenceIntervals.m
data1={55.96,56.54,57.58,55.13,57.48,56.06,59.93,58.30,52.57,58.46}
MeanCI[data1,ConfidenceLevel->0.95,KnownVariance->4]

输出结果为{55.5614,58.0406}

  1. 13.1,5.1,18.0,8.7,16.5,9.8,6.8,12.0,17.8,25.4,19.2,15.8,23.0,求σ的置信水平为0.95的置信区间
data2={13.1,5.1,18.0,8.7,16.5,9.8,6.8,12.0,17.8,25.4,19.2,15.8,23.0}
V=VarianceCI[data2,ConfidenceLevel->0.95]

输出结果为 {4.40589,10.1424}

相关文章

提交新的问题
点此拍照题目

添加新讨论