课件作者以及来源
内华达大学 Qiang Zhu教授 http://www.physics.unlv.edu/~qzhu/
特点
简单易懂、实例操作、基于jupyter notebook的课件。
内容介绍
- python 基础
- 积分
- 微分
- 差值
- 拟合
- 随机数
- 蒙特卡洛方法
- 优化算法
- 全局优化算法
- 机器学习
案例展示
# Let's start with a simple example, try to do integration on x^2 over [0,3]
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0,3,100)
y = x*x
plt.plot(x,y)
plt.xlabel('x')
plt.ylabel('$x^2#39;)
plt.xlim([0,3])
plt.show()
微分案例:
# Let's start with a simple example, try to do integration on x^2 over [0,3]
import matplotlib.pyplot as plt
import numpy as np
#define the function
f = lambda x: -x**4 + 4*x**3 + 2
#define the parameters
x_min, x_max = 0, 3
npoints = 100
x0 = (x_min+x_max)/2
deltax = 0.5
#draw the plot
x = np.linspace(x_min, x_max, npoints)
plt.plot(x,f(x))
#draw the derivative
x_1 = np.array([x0-deltax, x0, x0+deltax])
plt.plot(x_1,f(x_1),'-o')
for point in x_1:
linex, liney = [point, point], [0, f(point)]
plt.plot(linex, liney, color='black', linewidth=2.0)
plt.text(x_1[0]+deltax/2, f(x_1[0]+deltax/2)+1, r'backward difference', {'ha': 'left', 'va': 'bottom'}, rotation=90)
plt.text(x_1[1]+deltax/2, f(x_1[1]+deltax/2)+1, r'forwward difference', {'ha': 'left', 'va': 'bottom'}, rotation=90)
plt.xlabel('x')
plt.ylabel('$f(x)#39;)
plt.xlim([0,3])
plt.show()
课件获取
http://www.physics.unlv.edu/~qzhu/