Algorithm:实现LDA的Gibbs Gauss采样(绘制多图subplot)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41185868/article/details/82115195

import numpy as np
import matplotlib.pyplot as plt

N = 1000
# 初始化y, 可以任选一个值
y = 0
xs = []
ys = []

for i in range(N):
    # 更新x_t
    x = np.random.normal(0.8*y, 0.6)
    # 更新y_t
    y = np.random.normal(0.8*x, 0.6)
    xs.append(x)
    ys.append(y)

xs2, ys2 = np.random.multivariate_normal( [0, 0], [[1,0.8],[0.8,1]], N ).T

plt.subplot(211)
plt.title('gibbs Gauss')
plt.scatter(xs, ys)
plt.subplot(212)
plt.scatter(xs2, ys2)
plt.show()

猜你喜欢

转载自blog.csdn.net/qq_41185868/article/details/82115195