import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display,Math
nums = np.random.rand(1000)
minval = 2
maxval = 17
nums = nums*(maxval - minval) + minval
plt.plot(nums,'s')
plt.show()
plt.hist(nums)
plt.show()
nums = np.random.randn(1000)
plt.plot(nums, 's', alpha=.5)
plt.show()
plt.hist(nums)
plt.show()
Exercise
print('Normal distribution with:')
print('mean = 15')
print('standard deviation = 4.3')
desired_mean = 15
desired_std = 4.3
nums = np.random.randn(1000)
nums = nums - np.mean(nums) # mean: 0
nums = nums/np.std(nums) # std: 1
nums = nums*desired_std + desired_mean
plt.subplot(121)
plt.plot(nums, 's')
plt.subplot(122)
plt.hist(nums)
plt.show()
print('This distribution has a mean of %s and a standard deviation of %s' %(np.mean(nums), np.std(nums)))