Exemplo n.º 1
0
def sample_observation_diagonal_covariance(model, state, observ, hyperparams):
    """
    MCMC iteration (Gibbs sampling) for diagonal observation covariance
    matrix with inverse-gamma prior
    """

    # Calculate sufficient statistics using current state trajectory
    suffStats = smp.evaluate_observation_sufficient_statistics(state, observ)

    # Update hyperparameters
    a, b = smp.hyperparam_update_basic_ig_observation_variance(
        suffStats, model.parameters['H'], hyperparams['a0'], hyperparams['b0'])

    # Sample new parameter
    r = stats.invgamma.rvs(a, scale=b)
    model.parameters['R'] = r * np.identity(model.do)

    return model
def sample_observation_diagonal_covariance(model, state, observ, hyperparams):
    """
    MCMC iteration (Gibbs sampling) for diagonal observation covariance
    matrix with inverse-gamma prior
    """

    # Calculate sufficient statistics using current state trajectory
    suffStats = smp.evaluate_observation_sufficient_statistics(state, observ)

    # Update hyperparameters
    a,b = smp.hyperparam_update_basic_ig_observation_variance(
                                suffStats,
                                model.parameters['H'],
                                hyperparams['a0'],
                                hyperparams['b0'])

    # Sample new parameter
    r = stats.invgamma.rvs(a, scale=b)
    model.parameters['R'] = r*np.identity(model.do)

    return model
Exemplo n.º 3
0
    def sample_observation_diagonal_covariance(self):
        """
        MCMC iteration (Gibbs sampling) for diagonal observation covariance
        matrix with inverse-gamma prior
        """

        # Calculate sufficient statistics using current state trajectory
        suffStats = smp.evaluate_observation_sufficient_statistics(
            self.state, self.observ)

        # Update hyperparameters
        a, b = smp.hyperparam_update_basic_ig_observation_variance(
            suffStats, self.model.parameters['H'], self.hyperparams['a0'],
            self.hyperparams['b0'])

        # Sample new parameter
        r = stats.invgamma.rvs(a, scale=b)
        self.model.parameters['R'] = r * np.identity(self.model.do)

        # self.flt and self.lhood are no longer up-to-date
        self.filter_current = False
    def sample_observation_diagonal_covariance(self):
        """
        MCMC iteration (Gibbs sampling) for diagonal observation covariance
        matrix with inverse-gamma prior
        """

        # Calculate sufficient statistics using current state trajectory
        suffStats = smp.evaluate_observation_sufficient_statistics(self.state,
                                                                  self.observ)

        # Update hyperparameters
        a,b = smp.hyperparam_update_basic_ig_observation_variance(
                                    suffStats,
                                    self.model.parameters['H'],
                                    self.hyperparams['a0'],
                                    self.hyperparams['b0'])

        # Sample new parameter
        r = stats.invgamma.rvs(a, scale=b)
        self.model.parameters['R'] = r*np.identity(self.model.do)

        # self.flt and self.lhood are no longer up-to-date
        self.filter_current = False