Пример #1
0
def natural_sample(J, h, num_samples=None, rng=rng):
    sample_shape = (num_samples,) + h.shape if num_samples else h.shape
    J = -2*J
    if J.ndim == 1:
        return h / J + rng.normal(size=sample_shape) / np.sqrt(J)
    else:
        L = np.linalg.cholesky(J)
        noise = solve_triangular(L, rng.normal(size=sample_shape).T, trans='T')
        return solve_posdef_from_cholesky(L, h.T).T + noise.T
Пример #2
0
def natural_sample(J, h, num_samples=None, rng=rng):
    sample_shape = (num_samples,) + h.shape if num_samples else h.shape
    J = -2*J
    if J.ndim == 1:
        return h / J + rng.normal(size=sample_shape) / np.sqrt(J)
    else:
        L = np.linalg.cholesky(J)
        noise = solve_triangular(L, rng.normal(size=sample_shape).T, trans='T')
        return solve_posdef_from_cholesky(L, h.T).T + noise.T
Пример #3
0
def sample(mu, sigma, rng=rng):
    L = np.linalg.cholesky(sigma)
    return mu + np.dot(L, rng.normal(size=mu.shape))
Пример #4
0
def sample(mu, sigma, rng=rng):
    L = np.linalg.cholesky(sigma)
    return mu + np.dot(L, rng.normal(size=mu.shape))