# import statistics library as stat
#
import statistics as stat
#
# import matplotlib.pyplot as plt and NumPy as np
import matplotlib.pyplot as plt
import numpy as np
temps = [45, 51, 38, 42, 47, 51, 52, 55, 48, 43]
n = len(temps)
# for plotting purposes I have added an array of days from 1 to 10
days = np.linspace(1,n,n)
print ("The mean of the data is: ", stat.mean(temps))
mean = stat.mean(temps)
print ("The median of the data is: ", stat.median (temps))
median = stat.median(temps)
print ("The mode of the data is: ", stat.mode (temps))
mode = stat.mode(temps)
import math
print ("The variance of the data is: ", stat.variance(temps))
variance = stat.variance(temps)
print ("The standard deviation of the data is: ", stat.stdev(temps))
stdev = stat.stdev(temps)
The mean of the data is: 47.2
The median of the data is: 47.5
The mode of the data is: 51
The variance of the data is: 27.511111111111113
The standard deviation of the data is: 5.2451035367389185
# Plot the temperatures vs the days as a scatter plot using a red "x"
#
# Plot the mean as a horizontal line in green
#
# Illustrate 1 standard deviation away from the mean by drawing two horizonal lines in
# as dotted blue lines
x = np.linspace(1,1)
y = np.ones(len(x)) * mean
plt.plot(y,'g')
plt.plot(temps,days,'rx')
plt.plot(--b)
plt.show()
x = np.random.randint (100, 200, 15)
print (x)
[185 178 145 144 118 123 159 151 173 165 147 155 197 129 107]
y = np.random.uniform(size = 15)
print (y)
[0.15032713 0.50491213 0.62565675 0.60884641 0.44550286 0.10006794
0.72122352 0.48934242 0.76407569 0.65339732 0.90598596 0.03186287
0.30259437 0.09533486 0.79987429]
z = np.random.uniform(10,40,15)
print (z)
[34.60443026 20.27498006 22.58037158 22.19001724 22.70203938 33.52579204
38.45386753 15.83563899 10.83711255 12.41935493 33.77343773 14.39503837
34.36354087 21.64566102 11.23292368]
a = np.random.normal(size = 15)
print (a)
[ 1.01880173 2.58538927 0.95979436 -0.23154813 0.45592173 -0.26493642
1.55036026 -0.88699482 0.76201932 1.09497519 1.29762161 0.87081213
1.9204216 0.03329305 1.39482864]
b = 20 + a * (.5)
print (b)
[20.50940086 21.29269463 20.47989718 19.88422594 20.22796087 19.86753179
20.77518013 19.55650259 20.38100966 20.54748759 20.6488108 20.43540607
20.9602108 20.01664653 20.69741432]