关于方差如何用递推求避免后效性

我们将方差进行一个小小的推导:

n 2 ⋅ σ 2 = n ⋅ Σ i = 1 n ( x i − x ˉ ) = n ⋅ ( Σ i = 1 n x i 2 − 2 ⋅ x ˉ ⋅ Σ i = 1 n x + n ⋅ x 2 ) = n ⋅ Σ i = 1 n x i 2 − ( Σ i = 1 n x i ) 2 \begin{aligned} n^2\cdot \sigma^2 &= n\cdot\Sigma_{i = 1}^{n}(x_i - \bar x) \\ &= n\cdot(\Sigma_{i = 1}^{n}x_i^2 - 2 \cdot \bar x \cdot\Sigma_{i = 1}^{n}x+ n \cdot x^2) \\ &= n\cdot \Sigma_{i = 1}^{n}x_i^2 - (\Sigma_{i=1}^{n}x_i)^2 \end{aligned} n2σ2=nΣi=1n(xixˉ)=n(Σi=1nxi22xˉΣi=1nx+nx2)=nΣi=1nxi2(Σi=1nxi)2

此时我们设 a i = Σ i = 1 n x i a_i = \Sigma_{i=1}^{n}x_i ai=Σi=1nxi b i = Σ i = 1 n x i 2 b_i = \Sigma_{i=1}^{n}x_i^2 bi=Σi=1nxi2 ,则:

n 2 ⋅ σ 2 = n ⋅ b n − a n 2 = n ⋅ ( b n − 1 + x n 2 ) − ( a n − 1 + x n ) 2 = ( n ⋅ b n − 1 − a n − 1 ) + ( n − 1 ) ⋅ x n 2 − 2 ⋅ a n − 1 ⋅ x n \begin{aligned} n^2\cdot\sigma^2 &= n \cdot b_n - a_n^2 \\ & = n \cdot (b_{n - 1} + x_n^2) - (a_{n-1} + x_n)^2 \\ & = (n\cdot b_{n-1} - a_{n-1}) + (n - 1)\cdot x_n^2 - 2\cdot a_{n-1}\cdot x_n \end{aligned} n2σ2=nbnan2=n(bn1+xn2)(an1+xn)2=(nbn1an1)+(n1)xn22an1xn

于是方差就可以用递推求而避免后面加进来的数字产生影响了。

你可能感兴趣的:(数论,方差)