# 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)
temp_mean=stat.mean(temps)
stat.median(temps)
stat.mode(temps)
temp_std=stat.stdev(temps)
stat.variance(temps)
# Plot the temperatures vs the days as a scatter plot using a red "x"
plt.scatter(days,temps,c='red',marker='x')
#
# Plot the mean as a horizontal line in green
plt.axhline(y=temp_mean,color='green')
#
# Illustrate 1 standard deviation away from the mean by drawing two horizonal lines in
# as dotted blue lines
plt.axhline(y=temp_mean-temp_std,color='blue')
plt.axhline(y=temp_mean+temp_std,color='blue')
plt.show()
random_numbers=np.random.randint(100,200,15)
print(random_numbers)
[127 162 114 134 113 102 188 157 153 139 199 162 140 115 167]
random_floats=np.random.uniform(0,1,15)
print(random_floats)
[0.59898417 0.24534865 0.17170096 0.17979521 0.01349709 0.64348407
0.51472441 0.25775553 0.49933802 0.06197775 0.69237109 0.2079077
0.50876871 0.79984558 0.68220891]
random_floats_2=np.random.uniform(10,40,15)
print(random_floats_2)
[19.60860867 32.41054457 13.94738061 24.79305661 33.64360694 39.04809745
26.62479031 19.93567066 23.32287246 27.90273013 18.19627578 27.39525422
37.61561684 38.34792781 22.68097211]
normal_random=np.random.normal(0,1,15)
print(normal_random)
[-0.83587672 -0.04230693 -0.4063913 0.26963375 0.27950266 -1.9799162
2.06524415 1.08310213 -1.71236612 -1.46492177 -1.18218996 0.36553569
-0.96894982 -1.66861506 1.34061541]
normal_random_2=np.random.normal(20,0.5,15)
print(normal_random_2)
[19.95278156 20.37952646 19.79611422 19.45894523 20.04862493 19.62266974
19.59997975 20.59110971 19.42683579 20.44184826 20.44256775 20.01855812
19.66201513 20.08543569 19.13480404]