All Projects → aesara-devs → aeppl

aesara-devs / aeppl

Licence: MIT license
Tools for an Aesara-based PPL.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to aeppl

Stats Maths With Python
General statistics, mathematical programming, and numerical/scientific computing scripts and notebooks in Python
Stars: ✭ 381 (+728.26%)
Mutual labels:  probability, bayesian-statistics
blangSDK
Blang's software development kit
Stars: ✭ 21 (-54.35%)
Mutual labels:  bayesian-statistics
Stochastic
Generate realizations of stochastic processes in python.
Stars: ✭ 198 (+330.43%)
Mutual labels:  probability
symbolic-pymc
Tools for the symbolic manipulation of PyMC models, Theano, and TensorFlow graphs.
Stars: ✭ 58 (+26.09%)
Mutual labels:  symbolic-computation
From 0 To Research Scientist Resources Guide
Detailed and tailored guide for undergraduate students or anybody want to dig deep into the field of AI with solid foundation.
Stars: ✭ 247 (+436.96%)
Mutual labels:  probability
lm-scorer
📃Language Model based sentences scoring library
Stars: ✭ 264 (+473.91%)
Mutual labels:  probability
Quant Notes
Quantitative Interview Preparation Guide, updated version here ==>
Stars: ✭ 180 (+291.3%)
Mutual labels:  probability
Fluent-Random-Picker
Fluent Random Picker is a nice, performant, fluent way to pick random values. Probabilities can be specified, values can be weighted.
Stars: ✭ 26 (-43.48%)
Mutual labels:  probability
geostan
Bayesian spatial analysis
Stars: ✭ 40 (-13.04%)
Mutual labels:  bayesian-statistics
Luminescence
Development of the R package 'Luminescence'
Stars: ✭ 13 (-71.74%)
Mutual labels:  bayesian-statistics
Abacus
Advanced Combinatorics and Algebraic Number Theory Symbolic Computation library for JavaScript, Python
Stars: ✭ 16 (-65.22%)
Mutual labels:  symbolic-computation
Stanford Cme 106 Probability And Statistics
VIP cheatsheets for Stanford's CME 106 Probability and Statistics for Engineers
Stars: ✭ 242 (+426.09%)
Mutual labels:  probability
TransformVariables.jl
Transformations to contrained variables from ℝⁿ.
Stars: ✭ 52 (+13.04%)
Mutual labels:  bayesian-statistics
Pynomaly
Anomaly detection using LoOP: Local Outlier Probabilities, a local density based outlier detection method providing an outlier score in the range of [0,1].
Stars: ✭ 238 (+417.39%)
Mutual labels:  probability
statistical-rethinking-solutions
Solutions of practice problems from the Richard McElreath's "Statistical Rethinking" book.
Stars: ✭ 60 (+30.43%)
Mutual labels:  bayesian-statistics
Math Finance Cheat Sheet
Mathematical finance cheat sheet.
Stars: ✭ 186 (+304.35%)
Mutual labels:  probability
Kelvin
A powerful language for symbolic computation written in Swift.
Stars: ✭ 23 (-50%)
Mutual labels:  symbolic-computation
QuantumLattices.jl
Julia package for the construction of quantum lattice systems.
Stars: ✭ 79 (+71.74%)
Mutual labels:  symbolic-computation
SciLean
Scientific computing in Lean 4
Stars: ✭ 86 (+86.96%)
Mutual labels:  symbolic-computation
fattails
Code and Notes for fat-tailed statistics.
Stars: ✭ 41 (-10.87%)
Mutual labels:  probability

Tests Status Coverage Join the chat at https://gitter.im/aesara-devs/aeppl

aeppl provides tools for a[e]PPL written in Aesara.

Features

  • Convert graphs containing Aesara RandomVariables into joint log-probability graphs
  • Transforms for RandomVariables that map constrained support spaces to unconstrained spaces (e.g. the extended real numbers), and a rewrite that automatically applies these transformations throughout a graph
  • Tools for traversing and transforming graphs containing RandomVariables
  • RandomVariable-aware pretty printing and LaTeX output

Examples

Using aeppl, one can create a joint log-probability graph from a graph containing Aesara RandomVariables:

import aesara
from aesara import tensor as at

from aeppl import joint_logprob, pprint


# A simple scale mixture model
S_rv = at.random.invgamma(0.5, 0.5)
Y_rv = at.random.normal(0.0, at.sqrt(S_rv))

# Compute the joint log-probability
logprob, (y, s) = joint_logprob(Y_rv, S_rv)

Log-probability graphs are standard Aesara graphs, so we can compute values with them:

logprob_fn = aesara.function([y, s], logprob)

logprob_fn(-0.5, 1.0)
# array(-2.46287705)

Graphs can also be pretty printed:

from aeppl import pprint, latex_pprint


# Print the original graph
print(pprint(Y_rv))
# b ~ invgamma(0.5, 0.5) in R, a ~ N(0.0, sqrt(b)**2) in R
# a

print(latex_pprint(Y_rv))
# \begin{equation}
#   \begin{gathered}
#     b \sim \operatorname{invgamma}\left(0.5, 0.5\right)\,  \in \mathbb{R}
#     \\
#     a \sim \operatorname{N}\left(0.0, {\sqrt{b}}^{2}\right)\,  \in \mathbb{R}
#   \end{gathered}
#   \\
#   a
# \end{equation}

# Simplify the graph so that it's easier to read
from aesara.graph.rewriting.utils import rewrite_graph
from aesara.tensor.rewriting.basic import topo_constant_folding


logprob = rewrite_graph(logprob, custom_rewrite=topo_constant_folding)


print(pprint(logprob))
# s in R, y in R
# (switch(s >= 0.0,
#         ((-0.9189385175704956 +
#           switch(s == 0, -inf, (-1.5 * log(s)))) - (0.5 / s)),
#         -inf) +
#  ((-0.9189385332046727 + (-0.5 * ((y / sqrt(s)) ** 2))) - log(sqrt(s))))

Joint log-probabilities can be computed for some terms that are derived from RandomVariables, as well:

# Create a switching model from a Bernoulli distributed index
Z_rv = at.random.normal([-100, 100], 1.0, name="Z")
I_rv = at.random.bernoulli(0.5, name="I")

M_rv = Z_rv[I_rv]
M_rv.name = "M"

# Compute the joint log-probability for the mixture
logprob, (m, z, i) = joint_logprob(M_rv, Z_rv, I_rv)


logprob = rewrite_graph(logprob, custom_rewrite=topo_constant_folding)

print(pprint(logprob))
# i in Z, m in R, a in Z
# (switch((0 <= i and i <= 1), -0.6931472, -inf) +
#  ((-0.9189385332046727 + (-0.5 * (((m - [-100  100][a]) / [1. 1.][a]) ** 2))) -
#   log([1. 1.][a])))

Installation

The latest release of aeppl can be installed from PyPI using pip:

pip install aeppl

The current development branch of aeppl can be installed from GitHub, also using pip:

pip install git+https://github.com/aesara-devs/aeppl
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].