Skip to content

Ensembles with noisy realizations #1699

@arrjon

Description

@arrjon

Feature description
In Ensemble allow for noisy realizations of the model by adding noise after simulating.

Motivation/Application
For example, When using Ensemble to get the posterior predictive we are currently neglecting the noise model. This is okay for prediction of the clean state. However, for checking if the uncertainty of the posterior matches the data we need to noise on top of the simulation (as noise could be different per simulation if the variance is estimated. I think it would be nice in general to have the option to get noisy realizations.

from pypesto.ensemble import Ensemble
from pypesto.predict import AmiciPredictor

ensemble = Ensemble.from_sample(
    result,
    x_names=problem.x_names,
    lower_bound=problem.lb,
    upper_bound=problem.ub,
)

predictor = AmiciPredictor(problem.objective)

ensemble_prediction = ensemble.predict(
    predictor,
    engine=pypesto.engine.MultiProcessEngine(),
)

# add assumed noise on top
for o in ensemble_prediction.prediction_results:
    o.conditions[0].output = o.conditions[0].output + np.random.normal(0, 0.05, size=len(o.conditions[0].output))

# Credible bands
axes = visualize.sampling_prediction_trajectories(
    ensemble_prediction,
    levels=[99, 95, 80],
    title='Posterior predictions',
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions