Script to calculate Basic Statistics¶
Equation for the mean: $\mu_x = \sum_{i=1}^{N}\frac{x_i}{N}$¶
Equation for the standard deviation: $\sigma_x = \sqrt{\sum_{i=1}^{N}\left(x_i - \mu \right)^2}\frac{1}{N-1}$¶
Instructions:
(1) Before you write code, write an algorithm that describes the sequence of steps you will take to compute the mean and standard deviation for your samples. The algorithm can be written in pseudocode or as an itemized list.*
(2) Use 'for' loops to help yourself compute the average and standard deviation.
(3) Use for loops and conditional operators to count the number of samples within $1\sigma$ of the mean.
Note: It is not acceptable to use the pre-programmed routines for mean and st. dev., e.g. numpy.mean()
Edit this box to write an algorithm for computing the mean and std. deviation.¶
Write your code using instructions in the cells below.¶
In [1]:
# Put your Header information here. Name, creation date, version, etc.
In [2]:
# Import the matplotlib module here. No other modules should be used.
In [3]:
# Create a list variable that contains at least 25 elements. You can create this list any number of ways.
# This will be your sample.
In [4]:
# Pretend you do not know how long x is; compute it's length, N, without using functions or modules.
In [5]:
# Compute the mean of the elements in list x.
In [6]:
# Compute the std deviation, using the mean and the elements in list x.
In [7]:
# Use the 'print' command to report the values of average (mu) and std. dev. (sigma).
In [8]:
# Count the number of values that are within +/- 1 std. deviation of the mean.
# A normal distribution will have approx. 68% of the values within this range.
# Based on this criteria is the list normally distributed?
In [9]:
# Use print() and if statements to report a message about whether the data is normally distributed.
In [10]:
### Use Matplotlb.pyplot to make a histogram of x.
In [ ]: