Mean, Variance, Standard Deviation of Frequency Distribution

866 days ago by mineungi

$x_i$ $f_i$ $x_i f_i$
$x_1$ $f_1$ $x_1 f_1$
$\vdots$ $\vdots$ $\vdots$
$x_n$ $f_n$ $x_n f_n$

$ f_1 +f_2 +f_3 +\cdots+f_n =\displaystyle\sum_{i=1}^n x_i f_i =N$

$\begin{array}{rcl} \displaystyle \text{Mean }&:& m = \displaystyle \frac{\displaystyle\sum_{i=1}^n x_i f_i }{\displaystyle\sum_{i=1}^n f_i } =\displaystyle \frac{1}{N} \sum_{i=1}^n x_i f_i \\ && \\ \end{array}$

$\begin{array}{rcl} \displaystyle \displaystyle \text{Variance } : \sigma^2 &=&\displaystyle \frac{\displaystyle\sum_{i=1}^n(x_i-m)^2 f_i}{\displaystyle\sum_{i=1}^n f_i} =\displaystyle \frac{1}{N}\sum_{i=1}^n(x_i-m)^2 f_i =\displaystyle \frac{1}{N}\sum_{i=1}^n(x_i^2-2mx_i+m^2) f_i \\ &=&\displaystyle \frac{1}{N}\sum_{i=1}^n x_i^2 f_i - 2m \times \frac{1}{N}\sum_{i=1}^n x_i f_i +m^2 \times \frac{1}{N}\sum_{i=1}^n f_i \\ &=&\displaystyle \frac{1}{N}\sum_{i=1}^n x_i^2 f_i - 2m \times m +m^2 \times \frac{1}{N} \times N \\ &=&\displaystyle \frac{1}{N}\sum_{i=1}^n x_i^2 f_i - 2m^2 + m^2 =\displaystyle \frac{1}{N}\sum_{i=1}^n x_i^2 f_i -m^2\\ \end{array}$

$\begin{array}{rcl} \text{Standard Deviation } &:& \sigma =\sqrt{\sigma^2} \\ \end{array}$

list_of_class_boundaries=[50,60,70,80,90,100] class_frequency=[1,9,11,7,2] 
       
class_marks=[] for i in range(len(list_of_class_boundaries)-1): class_marks.insert(i,(list_of_class_boundaries[i]+list_of_class_boundaries[i+1])/2) 
       
%latex Class Marks$=\sage{latex(class_marks)}$ 
       
temp=copy(class_marks) temp[0]=list_of_class_boundaries[0] temp[len(class_marks)-1]=list_of_class_boundaries[len(list_of_class_boundaries)-1] histogram(temp,bins=len(temp), weights=class_frequency) 
       
mean_of_frequency_distribution=vector(class_frequency).dot_product(vector(class_marks))/sum(class_frequency) 
       
%latex $m=\displaystyle\sage{latex(mean_of_frequency_distribution)}$ 
       
squar_of_class_marks=[] for i in range(len(class_marks)): squar_of_class_marks.insert(i,class_marks[i]^2) 
       
%latex squar of class marks : $\displaystyle=\sage{latex(squar_of_class_marks)}$ 
       
variance_of_frequency_distribution=vector(squar_of_class_marks).dot_product(vector(class_frequency))/sum(class_frequency)-mean_of_frequency_distribution^2 
       
%latex $\sigma^2\displaystyle=\sage{latex(variance_of_frequency_distribution)}$ 
       
standard_deviation_of_frequency_distribution=sqrt(variance_of_frequency_distribution) 
       
%latex $\sigma\displaystyle=\sage{latex(standard_deviation_of_frequency_distribution.simplify())}$