CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-pymc3

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%

Overview
Eval results
Files

task.mdevals/scenario-9/

Logistic ODE Inference

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.

Capabilities

Configure ODE-based likelihood

  • Builds a probabilistic model using the dependency's ODE integrator to solve the logistic equation 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. @test

Sample posterior

  • Running inference with default arguments on the reference dataset yields posterior medians where the growth rate lies between 0.2 and 0.8 and the carrying capacity lies between 240 and 360, and exposes per-observation log-likelihood values. @test

Forecast trajectories

  • With posterior draws from the reference dataset and forecast_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

Implementation

@generates

API

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.
    """

Dependencies { .dependencies }

pymc { .dependency }

Probabilistic programming library with an ODE solver for embedding differential equations in models.

tile.json