Exemplo n.º 1
0
 def _construct_proposal_covariance(self, y):
     """
     Helper method to compute Cholesky factor of the Gaussian Kameleon-lite proposal centred at y.
     """
     # compute gradient projection
     grad_phi_y = feature_map_grad_single(y, self.omega, self.u)
     
     # construct covariance, adding exploration noise
     R = self.gamma2 * np.eye(self.D) + self.step_size * np.dot(grad_phi_y, (self.m ** 2) * np.dot(self.C, grad_phi_y.T))
     L_R = np.linalg.cholesky(R)
     
     return L_R
Exemplo n.º 2
0
    def _construct_proposal_covariance(self, y):
        """
        Helper method to compute Cholesky factor of the Gaussian Kameleon-lite proposal centred at y.
        """
        # compute gradient projection
        grad_phi_y = feature_map_grad_single(y, self.omega, self.u)

        # construct covariance, adding exploration noise
        R = self.gamma2 * np.eye(self.D) + self.step_size * np.dot(
            grad_phi_y, (self.m**2) * np.dot(self.C, grad_phi_y.T))
        L_R = np.linalg.cholesky(R)

        return L_R
Exemplo n.º 3
0
eta = 50.

plt.plot(Z[:, 0], Z[:, 1], 'bx')

# proposal plotting colors
colors = ['y', 'r', 'g', 'm', 'black']

# proposals centred at those points
Ys = np.array([[-20, 9.7], [-10, 0], [0,-3], [10, 0], [20, 9.7]])

for j in range(len(colors)):

    # pick point at random, embed, gradient
    y = Ys[j]
    phi_y = feature_map_single(y, omega, u)
    grad_phi_y = feature_map_grad_single(y, omega, u)
    
    # draw a number of proposals at the current point
    n_proposals = 100
    X_star = np.zeros((n_proposals, D))
    
    # generate proposal samples in feature space
    for i in range(n_proposals):
        plt.plot(y[0], y[1], '*', markersize=15, color=colors[j])
        
        # construct covariance, adding exploration noise
        R = eta**2 * np.dot(grad_phi_y, np.dot(C, grad_phi_y.T))
        L_R = np.linalg.cholesky(R)
        
        # sample proposal
        x_star = sample_gaussian(N=1, mu=y, Sigma=L_R, is_cholesky=True)