%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
a = np.array([1, 2, 3, 42])
a
array([ 1, 2, 3, 42])
b = np.linspace(0, 10, 50)
b
array([ 0. , 0.20408163, 0.40816327, 0.6122449 , 0.81632653, 1.02040816, 1.2244898 , 1.42857143, 1.63265306, 1.83673469, 2.04081633, 2.24489796, 2.44897959, 2.65306122, 2.85714286, 3.06122449, 3.26530612, 3.46938776, 3.67346939, 3.87755102, 4.08163265, 4.28571429, 4.48979592, 4.69387755, 4.89795918, 5.10204082, 5.30612245, 5.51020408, 5.71428571, 5.91836735, 6.12244898, 6.32653061, 6.53061224, 6.73469388, 6.93877551, 7.14285714, 7.34693878, 7.55102041, 7.75510204, 7.95918367, 8.16326531, 8.36734694, 8.57142857, 8.7755102 , 8.97959184, 9.18367347, 9.3877551 , 9.59183673, 9.79591837, 10. ])
np.sin(b)
array([ 0. , 0.20266794, 0.39692415, 0.57470604, 0.72863478, 0.85232157, 0.94063279, 0.98990308, 0.99808748, 0.96484631, 0.89155923, 0.78126802, 0.63855032, 0.46932961, 0.2806294 , 0.08028167, -0.12339814, -0.32195632, -0.50715171, -0.67129779, -0.80758169, -0.91034694, -0.97532829, -0.99982867, -0.9828312 , -0.92504137, -0.82885774, -0.6982724 , -0.53870529, -0.35677924, -0.16004509, 0.04333173, 0.24491007, 0.43632343, 0.6096272 , 0.75762842, 0.8741843 , 0.9544572 , 0.99511539, 0.99447137, 0.95255185, 0.8710967 , 0.75348673, 0.60460332, 0.43062587, 0.23877532, 0.0370144 , -0.16628279, -0.36267843, -0.54402111])
_ = plt.plot(b, np.sin(b))
plt.plot(b, np.sin(b), label='f(x) = sin(x)')
plt.plot(b, np.cos(2 * b), label='f(x) = cos(2x)')
_ = plt.legend(loc='lower right')
x = np.random.normal(loc=0, scale=1.0, size=1000)
x.shape
(1000,)
x.dtype
dtype('float64')
x[:10]
array([-1.74725782, -0.21666812, -0.03585392, -0.89125978, 0.34458167, 0.16602813, 0.00856297, -0.12466605, -0.74936856, -0.42467096])
np.mean(x), np.std(x)
(-0.024093868368155413, 1.0055750968579782)
np.min(x), np.max(x)
(-3.0050925336249126, 2.9444565659244519)
_ = plt.plot(x)
_ = plt.hist(x, bins=20)
_ = plt.plot(np.cumsum(x))