In [20]:
import numpy as np
import matplotlib.pyplot as mp
d=np.array([45,32,17,28,33,26])
print(d)
print(d[:-1])
print(np.diff(d))
returns=np.diff(d)/d[:-1]
print(returns)
print(np.mean(returns),'+-',np.std(returns))
mp.clf()
mp.plot([0,1],[0,2])
mp.show()


[45 32 17 28 33 26]
[45 32 17 28 33]
[-13 -15  11   5  -7]
[-0.28888889 -0.46875     0.64705882  0.17857143 -0.21212121]
-0.0288259697819 +- 0.398646950269

In [23]:
import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(0, 10, 1000)
y = np.sin(x)
z = np.cos(x**2)

plt.clf()
plt.figure(figsize=(8,4))
plt.plot(x,y,label="$sin(x)$",color="red",linewidth=2)
plt.plot(x,z,"b--",label="$cos(x^2)$")
plt.xlabel("Time(s)")
plt.ylabel("Volt")
plt.title("PyPlot First Example")
plt.ylim(-1.2,1.2)
plt.legend()
plt.show()


<matplotlib.figure.Figure at 0x7f39fbe22438>

In [ ]: