Question
Using Python. Write a program that computes the standard deviation of a set of floating point numbers that the user enters. First the user will
Using Python. Write a program that computes the standard deviation of a set of floating point numbers that the user enters. First the user will say how many numbers N are to follow. Then the program will ask for and read in each floating point number. Finally it will write out the standard deviation. The standard deviation of a set of numbers Xi is: SD = Math.sqrt( avgSquare - avg 2 ) Here, avg is the average of the N numbers, and avg 2 is its square. avgSquare is the average of Xi * Xi. In other words, this is the average of the squared value of each floating point number. For example, if N = 4, say the numbers were: Xi Xi * Xi 2.0 4.0 3.0 9.0 1.0 1.0 2.0 4.0 ----- ------ sum 8.0 18.0 then avg = 8.0/4 = 2.0 avg 2 = 4.0 avgSquare = 18.0/4 = 4.5 SD = Math.sqrt( 4.5 - 4.0 ) = Math.sqrt( .5 ) = 0.7071067812 To do this you will need to do several things inside the loop body for each floating point value as it comes in: add it to a sum, square it and add it to a sum of squares. Then after the loop is finished apply the formula
Step 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