Question: Standard deviation Open the file lab4.csv. This file has 3 numbers per-line, separated by commas. Calculate the mean and standard deviation of each column of
Standard deviation
Open the file lab4.csv. This file has 3 numbers per-line, separated by commas.
Calculate the mean and standard deviation of each column of the file, using the formula:
=Ni=1(xix)2N1=i=1N(xix)2N1
Where is standard deviation, xx is the mean of the dataset, NN is the number of elements in the dataset, and xixi is an element of the dataset at spot ii.
You will need to:
- open the file.
- Initialize 3 list accumulators.
- Iterate over the lines of the file in a for loop and accumulate the values in the columns.
- Compute the average (either do this inside the loop with a running sum or use the sum function on your lists).
Once you have the mean xx, calculate the standard deviation using a second for loop.
Your output should look like:
The mean of column 1 is 50.30, and the standard deviation is 28.81 The mean of column 2 is 499.79, and the standard deviation is 290.16 The mean of column 3 is 5011.12, and the standard deviation is 2874.15
Standard deviations from the mean
Add to your program from the previous part to ask for numerical input from the user. Find how many standard deviations from the mean the input is.
The formula for deviations from the mean is:
deviationsFromMean=|xx|deviationsFromMean=|xx|
Where is the standard deviation, xx is the mean of the dataset, and xx is the data the user provided.
Give me a number : > 50 This number is 0000.0104 standard deviations from the mean for column 1. This number is 0001.5501 standard deviations from the mean for column 2. This number is 0001.7261 standard deviations from the mean for column 3.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
