$x_i$ 의 평균, 분산, 표준편차(Mean, Variance, Standard Deviation of $x_i$)[Sage Math이용]

자료의 Nims 서버의 Sage Math 주소 : http://sage.nims.re.kr/home/pub/268

 
아래는 Sage Math의 Text 파일이다. 위의 Nims 서버와 같은 내용인데, 혹시나 Nims 서버가 없어지는 경우를 대비하여 Text 형식을 아래에 붙여 놓았다.

$\begin{array}{rcl}
\displaystyle \text{Mean : } m &=&\displaystyle\frac{x_1+x_2+x_3+\cdots+x_n}{n} \\
&=&\displaystyle \frac{1}{n}\sum_{i=1}^n x_i \\
\end{array}$
<p>
$\begin{array}{rcl}
\displaystyle \displaystyle \text{Variance : }
\sigma^2& =&\displaystyle\frac{(x_1-m)^2+(x_2-m)^2+\cdots+(x_n-m)^2}{n} \\
&=&\displaystyle \frac{1}{n}\sum_{i=1}^n(x_i-m)^2
=\displaystyle \frac{1}{n}\sum_{i=1}^n(x_i^2-2mx_i+m^2) \\
&=&\displaystyle \frac{1}{n}\sum_{i=1}^n x_i^2
- 2m \times \frac{1}{n}\sum_{i=1}^n x_i
+m^2 \times \frac{1}{n}\sum_{i=1}^n 1 \\
&=&\displaystyle \frac{1}{n}\sum_{i=1}^n x_i^2
- 2m \times m
+m^2 \times \frac{1}{n} \times n \\
&=&\displaystyle \frac{1}{n}\sum_{i=1}^n x_i^2 - 2m^2 + m^2
=\displaystyle \frac{1}{n}\sum_{i=1}^n x_i^2 -m^2\\
\end{array}$
<p>
$\text{Standard Deviation } : \sigma=\sqrt{\sigma^2}$
sage: variate_list=[1,2,3,4,5]
sage: %latex
sage: Variate list: $\displaystyle=\sage{latex(variate_list)}$
sage: mean_of_variate_list=mean(variate_list)
sage: %latex
sage: $m=\displaystyle\sage{latex(mean_of_variate_list)}$
sage: variance_of_variate_list=variance(variate_list, bias=True)
sage: %latex
sage: $\sigma^2\displaystyle=\sage{latex(variance_of_variate_list)}$
sage: standard_deviation_of_variate_list=std(variate_list, bias=True)
sage: %latex
sage: $\sigma\displaystyle=\sage{latex(standard_deviation_of_variate_list.simplify())}$
sage: squar_of_variate_list=[]
sage: for i in range(len(variate_list)):
... squar_of_variate_list.insert(i,variate_list[i]^2)
sage: %latex
sage: squar of variate list : $\displaystyle=\sage{latex(squar_of_variate_list)}$
sage: mean(squar_of_variate_list)-mean(variate_list)^2
2

 

 

Geogebra와 수학의 시각화 : http://min7014.iptime.org/math/2017063002.htm