def init_same_param_shapes(cls):
     M = 10
     D = 8
     prior = TPrior(D // 2, mu_scale=1.0, scale_scale=5.0)
     priors = [prior] * M
     simulators = [
         MultivariateTSimulator(df) for df in np.arange(1, 101, M)
     ]
     generative_model = MetaGenerativeModel(model_prior, priors, simulators)
     return generative_model
 def init_different_param_shapes(cls):
     priors = [
         ex.priors.model1_params_prior, ex.priors.model2_params_prior,
         ex.priors.model3_params_prior
     ]
     simulators = [
         ex.simulators.forward_model1, ex.simulators.forward_model2,
         ex.simulators.forward_model3
     ]
     generative_model = MetaGenerativeModel(model_prior, priors, simulators)
     return generative_model
 def test_meta_generative_model_different_param_shapes(self):
     priors = [
         ex.priors.model1_params_prior, ex.priors.model2_params_prior,
         ex.priors.model3_params_prior
     ]
     simulators = [
         ex.simulators.forward_model1, ex.simulators.forward_model2,
         ex.simulators.forward_model3
     ]
     generative_model = MetaGenerativeModel(model_prior, priors, simulators)
     _model_indices, _params, _sim_data = generative_model(n_sim=16,
                                                           n_obs=150)
    def test_same_data_transform(self):
        def data_transform(x):
            noise = 0.001 * np.random.random(x.shape)
            return x + noise

        M = 10
        D = 8
        prior = TPrior(D // 2, mu_scale=1.0, scale_scale=5.0)
        priors = [prior] * M
        simulators = [
            MultivariateTSimulator(df) for df in np.arange(1, 101, M)
        ]

        _generative_model = MetaGenerativeModel(model_prior=model_prior,
                                                priors=priors,
                                                simulators=simulators,
                                                data_transforms=data_transform)
    def test_same_param_transform(self):
        def param_transform(x):
            return np.exp(x)

        M = 10
        D = 8
        prior = TPrior(D // 2, mu_scale=1.0, scale_scale=5.0)
        priors = [prior] * M
        simulators = [
            MultivariateTSimulator(df) for df in np.arange(1, 101, M)
        ]

        _generative_model = MetaGenerativeModel(
            model_prior=model_prior,
            priors=priors,
            simulators=simulators,
            param_transforms=param_transform)
Exemple #6
0
    def test_same_param_and_data_transform(self):
        def data_transform(x):
            noise = 0.001 * np.random.random(x.shape)
            return x + noise

        def param_transform(x):
            return np.exp(x)

        M = 10
        D = 8
        prior = ex.priors.TPrior(D // 2, mu_scale=1.0, scale_scale=5.0)
        priors = [prior] * M
        simulators = [
            ex.simulators.MultivariateT(df) for df in np.arange(1, 101, M)
        ]

        _generative_model = MetaGenerativeModel(
            model_prior=ex.priors.model_prior,
            priors=priors,
            simulators=simulators,
            param_transforms=param_transform,
            data_transforms=data_transform)
    def test_individual_param_and_data_transform(self):
        param_transforms = [
            lambda x: np.exp(x), None, lambda x: np.round(x, 3)
        ]

        data_transforms = [
            lambda x: x + np.random.random(x.shape), lambda x: np.exp(x), None
        ]

        M = 3
        D = 4
        prior = TPrior(D // 2, mu_scale=1.0, scale_scale=5.0)
        priors = [prior] * M
        simulators = [
            MultivariateTSimulator(df)
            for df in np.round(np.linspace(1, 101, M))
        ]

        _generative_model = MetaGenerativeModel(
            model_prior=model_prior,
            priors=priors,
            simulators=simulators,
            param_transforms=param_transforms,
            data_transforms=data_transforms)