探索规范化

多元正态分布的各种归一化。

  1. import matplotlib.pyplot as plt
  2. import matplotlib.colors as mcolors
  3. import numpy as np
  4. from numpy.random import multivariate_normal
  5. data = np.vstack([
  6. multivariate_normal([10, 10], [[3, 2], [2, 3]], size=100000),
  7. multivariate_normal([30, 20], [[2, 3], [1, 3]], size=1000)
  8. ])
  9. gammas = [0.8, 0.5, 0.3]
  10. fig, axes = plt.subplots(nrows=2, ncols=2)
  11. axes[0, 0].set_title('Linear normalization')
  12. axes[0, 0].hist2d(data[:, 0], data[:, 1], bins=100)
  13. for ax, gamma in zip(axes.flat[1:], gammas):
  14. ax.set_title(r'Power law $(\gamma=%1.1f)$' % gamma)
  15. ax.hist2d(data[:, 0], data[:, 1],
  16. bins=100, norm=mcolors.PowerNorm(gamma))
  17. fig.tight_layout()
  18. plt.show()

探索规范化示例

参考

此示例中显示了以下函数,方法,类和模块的使用:

  1. import matplotlib
  2. matplotlib.colors
  3. matplotlib.colors.PowerNorm
  4. matplotlib.axes.Axes.hist2d
  5. matplotlib.pyplot.hist2d

下载这个示例