Exemplo n.º 1
0
    print(sampler.sample_sgrld(epsilon=0.1, preconditioner=preconditioner).project_parameters())


## Using Evaluator
from sgmcmc_ssm import SamplerEvaluator
from sgmcmc_ssm.metric_functions import (
        sample_function_parameters,
        noisy_logjoint_loglike_metric,
        metric_function_parameters,
        )

metric_functions = [
        noisy_logjoint_loglike_metric(),
        metric_function_parameters(
                parameter_names=['A', 'Q', 'C', 'R'],
                target_values=[parameters.A, parameters.Q,
                    parameters.C, parameters.R],
                metric_names = ['mse', 'mse', 'mse', 'mse'],
                )
        ]

sample_functions = sample_function_parameters(
        ['A', 'Q', 'LQinv', 'C', 'R', 'LRinv'],
        )

sampler = SLDSSampler(**parameters.dim)
sampler.setup(data['observations'], prior)
sampler.init_sample_latent() ## THIS IS IMPORTANT
evaluator = SamplerEvaluator(
        sampler=sampler,
        metric_functions=metric_functions,
        sample_functions=sample_functions,
Exemplo n.º 2
0
        ).project_parameters())


## Using Evaluator
from sgmcmc_ssm import SamplerEvaluator
from sgmcmc_ssm.metric_functions import (
        sample_function_parameters,
        noisy_logjoint_loglike_metric,
        metric_function_parameters,
        )

metric_functions = [
        noisy_logjoint_loglike_metric(kind='pf', N=1000),
        metric_function_parameters(
                parameter_names=['A', 'LQinv', 'LRinv'],
                target_values=[parameters.A, parameters.LQinv, parameters.LRinv],
                metric_names = ['mse', 'mse', 'mse'],
                )
        ]

sample_functions = sample_function_parameters(
        ['A', 'Q', 'LQinv', 'R', 'LRinv'],
        )

sampler = SVMSampler(**parameters.dim)
sampler.setup(data['observations'], prior)
evaluator = SamplerEvaluator(
        sampler=sampler,
        metric_functions=metric_functions,
        sample_functions=sample_functions,
        )
Exemplo n.º 3
0
# Setup my_evaluators
from sgmcmc_ssm.evaluator import SamplerEvaluator
from sgmcmc_ssm.metric_functions import (
    metric_function_from_sampler,
    metric_function_parameters,
    metric_compare_x,
    noisy_logjoint_loglike_metric,
    sample_function_parameters,
)
parameter_names2 = ['A', 'C', 'Q', 'R']
my_metric_functions = [
    metric_function_parameters(
        parameter_names2,
        target_values=[
            getattr(my_data['parameters'], parameter_name)
            for parameter_name in parameter_names2
        ],
        metric_names=['mse' for parameter_name in parameter_names2],
    ),
    metric_compare_x(my_data['latent_vars']),
    metric_function_from_sampler("predictive_loglikelihood"),
    noisy_logjoint_loglike_metric(),
]
my_sample_functions = [
    sample_function_parameters(parameter_names2 + ['LRinv', 'LQinv']),
]
my_evaluators = {
    "{0}_{1}".format(*key):
    SamplerEvaluator(sampler,
                     my_metric_functions,
                     my_sample_functions,
Exemplo n.º 4
0
    metric_function_from_sampler,
    metric_function_parameters,
    metric_compare_x,
    metric_compare_z,
    noisy_logjoint_loglike_metric,
    sample_function_parameters,
)
parameter_names = ['pi']
parameter_names2 = ['A', 'Q']
parameter_names3 = ['C', 'R']
my_metric_functions = [
    metric_function_parameters(
        parameter_names,
        target_values=[
            getattr(my_data['parameters'], parameter_name)
            for parameter_name in parameter_names
        ],
        metric_names=['logmse' for parameter_name in parameter_names],
        criteria=[min for parameter_name in parameter_names],
        double_permutation_flag=True,
    ),
    metric_function_parameters(
        parameter_names,
        target_values=[
            getattr(my_data['parameters'], parameter_name)
            for parameter_name in parameter_names
        ],
        metric_names=['mse' for parameter_name in parameter_names],
        criteria=[min for parameter_name in parameter_names],
        double_permutation_flag=True,
    ),
    metric_function_parameters(
Exemplo n.º 5
0
        ).project_parameters())


## Using Evaluator
from sgmcmc_ssm import SamplerEvaluator
from sgmcmc_ssm.metric_functions import (
        sample_function_parameters,
        noisy_logjoint_loglike_metric,
        metric_function_parameters,
        )

metric_functions = [
        noisy_logjoint_loglike_metric(kind='pf', N=1000),
        metric_function_parameters(
                parameter_names=['alpha', 'beta', 'gamma', 'tau'],
                target_values=[parameters.alpha, parameters.beta,
                    parameters.gamma, parameters.tau],
                metric_names = ['mse', 'mse', 'mse', 'mse'],
                )
        ]

sample_functions = sample_function_parameters(
        ['alpha', 'beta', 'gamma', 'tau'],
        )

sampler = GARCHSampler(**parameters.dim)
sampler.setup(data['observations'], prior)
evaluator = SamplerEvaluator(
        sampler=sampler,
        metric_functions=metric_functions,
        sample_functions=sample_functions,
        )