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%
Utilities for building PyTensor-friendly graphs that expose log densities, log-tail probabilities, and quantiles for a univariate Gaussian defined by a supplied mean and standard deviation.
[-1.0, 0.0, 1.0], mean 0.0, and scale 1.0, returns log densities approximately [-1.4189, -0.9189, -1.4189] while preserving the input shape. @test0.0, mean 0.0, and scale 0.5, returns a log density around -0.2258. @test1.5 under mean 0.0 and scale 1.0, returns the log probability of being at or below the value, near -0.0691. @test-2.0 under mean 0.0 and scale 1.0, returns the log probability of being at or below the value, near -3.7832. @test0.975 with mean 0.0 and scale 1.0, returns a quantile near 1.95996. @test0.25 with mean 2.0 and scale 0.5, returns a quantile near 1.66276. @test@generates
from typing import Sequence
import numpy as np
import pytensor.tensor as pt
ArrayLike = Sequence[float] | np.ndarray | pt.TensorVariable
def elementwise_log_density(values: ArrayLike, mean: float, sigma: float) -> pt.TensorVariable:
"""
Build a graph returning the per-observation log density for the defined variable.
Preserves input shape and supports symbolic inputs.
"""
...
def tail_log_cdf(value: float | pt.TensorVariable, mean: float, sigma: float) -> pt.TensorVariable:
"""Build a graph returning the log probability that the variable is less than or equal to the supplied value."""
...
def quantile(probability: float | pt.TensorVariable, mean: float, sigma: float) -> pt.TensorVariable:
"""Build a graph returning the value whose cumulative probability matches the supplied probability."""
...Probabilistic programming runtime providing log-probability evaluation and distribution-aware math for PyTensor graphs. @satisfied-by
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10