Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with Theano
Agent Success
Agent success rate when using this tile
68%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.94x
Baseline
Agent success rate without this tile
72%
Estimate logistic growth parameters from noisy population counts by embedding a first-order ODE inside a probabilistic model, then forecast future counts from the inferred parameters.
dN/dt = r*N*(1 - N/K) over time_points while linking the solution to observed_counts with Gaussian noise of scale observation_sigma. Uses time_points=[0,1,2,3,4], observed_counts=[50,82,131,192,236], initial_population=50, and observation_sigma=12 in the reference test. @testforecast_times=[5,6,7], produces posterior predictive samples whose means are non-decreasing across time and stay within 5% above the inferred carrying capacity. @test@generates
from typing import Iterable, Sequence, Tuple, Optional
import numpy as np
def build_logistic_model(
time_points: Sequence[float],
observed_counts: Sequence[float],
initial_population: float,
observation_sigma: float,
) -> "ProbabilisticModel":
"""
Create and return a probabilistic model that embeds the logistic growth ODE and links observed counts to the ODE solution with Gaussian noise.
- time_points and observed_counts are aligned; time zero is included.
- The model exposes latent parameters for the intrinsic growth rate and carrying capacity.
- The model allows updating observed_counts of the same length without rebuilding the ODE definition.
"""
def sample_posterior(
model: "ProbabilisticModel",
draws: int = 1000,
tune: int = 1000,
random_seed: Optional[int] = None,
) -> "InferenceResult":
"""
Run gradient-based MCMC on the provided model and return posterior samples, including log likelihood contributions for the observed counts.
"""
def forecast_counts(
inference: "InferenceResult",
forecast_times: Sequence[float],
initial_population: float,
) -> Tuple[np.ndarray, np.ndarray]:
"""
Generate posterior predictive samples for the logistic trajectory at forecast_times using the same ODE integrator rather than a custom solver.
Returns a tuple (samples, summary_mean) where:
- samples is an array shaped (posterior_draws, len(forecast_times)) of simulated counts.
- summary_mean is a 1D array of posterior predictive means for each forecast time.
"""Probabilistic programming library with an ODE solver for embedding differential equations in models.
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10