Answered step by step
Verified Expert Solution
Question
1 Approved Answer
need step by step algorithm to this code Problem Statement-1: Write a program to calculate the standard deviation and variance. Source code -: #calculating standard
need step by step algorithm to this code
Problem Statement-1: Write a program to calculate the standard deviation and variance. Source code -: \#calculating standard deviation x=[2,7,3,12,9] x \#calculating mean \[ \begin{array}{l} \text { sum_x=0 } \\ \text { for i in range }(0, \text { len }(x)) \text { : } \\ \quad \text { sum_ } x=\text { sum_ } x+x[i] \\ \text { mean_x }=\text { sum_x/(len }(x)) \\ \text { mean_ } x=\text { round(mean_x,3) } \\ \text { print("Mean is } \cdots \text { "_-. }>\text {,mean_ } x) \end{array} \] \#For each data point, find the sum of square of its distance to the mean. \[ \begin{array}{l} \text { sum_xx=0 } \\ \text { for i in range(0,len(x)): } \\ a=\text { mean_x-x[i] } \\ a=a^{* * *} 2 \text {; } \\ \quad \text { sum_xx=sum_xx+a } \\ \text { sum_xx=round(sum_xx,3) } \\ \text { print(sum_xx) } \end{array} \] \#Divide sum by the number of data points. sum_ xx= sum_ xx/ len( x) sum_xx=round(sum_xx,3) print(sum_xx) \#calculate standard deviation import math standard_deviation=math.sqrt(sum_xx) standard_deviation=round(standard_deviation,3) print("standard deviation _-_ > "standard_deviation) \#Variance is the square of standard deviation. \#calculating variance variance = standard_deviation**2 print("variance > ",round(variance,3)) Mean is >6.6 69.2 13.84 standard deviation >3.72 variance >13.838Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started