ToyARK13.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:bnpy 作者: bnpy 项目源码 文件源码
def plotSequenceForRotatingState(degPerStep, Sigma, T=1000):
    theta = degPerStep * np.pi / 180.  # radPerStep
    A = np.asarray([
        [np.cos(theta), -np.sin(theta)],
        [np.sin(theta), np.cos(theta)],
    ])
    Sigma = np.asarray(Sigma)
    if Sigma.size == 1:
        Sigma = Sigma * np.eye(2)
    elif Sigma.size == 2:
        Sigma = np.diag(Sigma)

    X = np.zeros((T, 2))
    X[0, :] = [1, 0]
    for t in xrange(1, T):
        X[t] = np.random.multivariate_normal(np.dot(A, X[t - 1]), Sigma)

    pylab.plot(X[:, 0], X[:, 1], '.')
    pylab.axis([-4, 4, -4, 4])
    pylab.axis('equal')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号