Exemple #1
0
    def __call__(self , i_particle):

        rho = 1.e37
        prior_obj = Prior(self.prior_dict)
        while rho > self.eps_t:
           theta_star = utils.weighted_sampling(self.theta_t, self.w_t)
           np.random.seed()
           theta_starstar = np.random.multivariate_normal(theta_star, self.sig_t, 1)[0]
           #theta_starstar = multivariate_normal(theta_star, self.sig_t).rvs(size=1)
           model_starstar = self.model(theta_starstar)
           rho = self.distance(self.data, model_starstar)

        p_theta = prior_obj.pi_priors(theta_starstar)
        w_starstar = p_theta / np.sum(self.w_t * \
                                      utils.better_multinorm(theta_starstar,
                                                             self.theta_t,
                                                             self.sig_t) )

        pool_list = [np.int(i_particle)]
        theta_starstar = np.atleast_1d(theta_starstar)
        for i_param in xrange(self.n_params):
           pool_list.append(theta_starstar[i_param])
           pool_list.append(w_starstar)
           pool_list.append(rho)

        return pool_list
Exemple #2
0
    def __call__(self , i_particle):

        rho = 1.e100
        prior_obj = Prior(self.prior_dict)

        while np.all(rho < self.eps_t)==False:
        
           theta_star = utils.weighted_sampling(self.theta_t, self.w_t)
           theta_starstar = np.random.multivariate_normal(theta_star, self.sig_t, 1)[0]
        
           while np.all((prior_range[:,0] < theta_starstar)&(theta_starstar < prior_range[:,1]))==False:

              theta_star = utils.weighted_sampling(self.theta_t, self.w_t)
              theta_starstar = np.random.multivariate_normal(theta_star, self.sig_t).rvs(size=1)
        
           model_starstar = self.model(theta_starstar)
           rho = self.distance(self.data, model_starstar)

        p_theta = prior_obj.pi_priors(theta_starstar)
        w_starstar = p_theta / np.sum(self.w_t * \
                                      utils.better_multinorm(theta_starstar,
                                                             self.theta_t,
                                                             self.sig_t) )

        pool_list = [np.int(i_particle)]
        theta_starstar = np.atleast_1d(theta_starstar)
        for i_param in xrange(self.n_params):
           pool_list.append(theta_starstar[i_param])
        pool_list.append(w_starstar)
        for r in rho:
            pool_list.append(r)

        return np.array(pool_list)