画图
import numpy as np
import matplotlib.pylab as pl
x = np.random.uniform(1, 100, 1000) # uniform:从一个均匀分布[1,100)中随机采样,注意定义域是左闭右开,数量为1000
y = np.log(x) + np.random.normal(0, 0.3, 1000) # normal:正态分布,均值为0,标准差为0.3,
pl.scatter(x, y, s=1, label="log(x) with noise") # scatter:散点图,s为原点的半径大小
pl.plot(np.arange(1, 100), np.log(np.arange(1, 100)), c="b", label="log(x) true function")
pl.xlabel("x")
pl.ylabel("f(x) = log(x)")
pl.legend(loc="best") # 图例
pl.title("A basic log function")
pl.show()