{"id":19671544,"url":"https://github.com/aesara-devs/aeppl","last_synced_at":"2025-10-27T01:16:54.570Z","repository":{"id":37430545,"uuid":"371181735","full_name":"aesara-devs/aeppl","owner":"aesara-devs","description":"Tools for an Aesara-based PPL.","archived":false,"fork":false,"pushed_at":"2024-04-29T07:33:35.000Z","size":754,"stargazers_count":62,"open_issues_count":44,"forks_count":22,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-01T14:46:53.387Z","etag":null,"topics":["bayesian-statistics","modeling-and-simulation","ppl","probability","statistics","symbolic-computation","term-rewriting"],"latest_commit_sha":null,"homepage":"https://aeppl.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aesara-devs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null}},"created_at":"2021-05-26T22:17:30.000Z","updated_at":"2024-06-17T08:49:32.290Z","dependencies_parsed_at":"2024-06-23T10:30:43.108Z","dependency_job_id":null,"html_url":"https://github.com/aesara-devs/aeppl","commit_stats":{"total_commits":245,"total_committers":16,"mean_commits":15.3125,"dds":0.4040816326530612,"last_synced_commit":"8d98eaddc6089a31b48715d143193cdaf52e5bbf"},"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesara-devs%2Faeppl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesara-devs%2Faeppl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesara-devs%2Faeppl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aesara-devs%2Faeppl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aesara-devs","download_url":"https://codeload.github.com/aesara-devs/aeppl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247557767,"owners_count":20958047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bayesian-statistics","modeling-and-simulation","ppl","probability","statistics","symbolic-computation","term-rewriting"],"created_at":"2024-11-11T17:09:06.923Z","updated_at":"2025-10-27T01:16:54.511Z","avatar_url":"https://github.com/aesara-devs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"./docs/source/_static/aeppl_logo.png\" alt=\"AePPL Logo\" width=400\u003e\u003c/img\u003e\n\n# AePPL\n\n[![Pypi][pypi-badge]][pypi]\n[![Downloads][downloads-badge]][releases]\n[![Contributors][contributors-badge]][contributors]\n \u003c/br\u003e\n[![Gitter][gitter-badge]][gitter]\n[![Discord][discord-badge]][discord]\n[![Twitter][twitter-badge]][twitter]\n\nAeppl provides tools for a[e]PPL written in [Aesara](https://github.com/aesara-devs/aesara).\n\n*Build arbitrarily complex probabilistic models. If it is mathematically defined, AePPL will support it.*\n\n[Features](#features) •\n[Get started](#get-started) •\n[Install](#install) •\n[Get help](#get-help) •\n[Contribute](#contribute)\n\n\u003c/div\u003e\n\n\n## Features\n\n- Convert graphs containing Aesara `RandomVariable`s into joint\n  log-probability graphs\n- Transforms for `RandomVariable`s that map constrained support spaces to\n  unconstrained spaces (e.g. the extended real numbers), and a rewrite that\n  automatically applies these transformations throughout a graph\n- Tools for traversing and transforming graphs containing `RandomVariable`s\n- `RandomVariable`-aware pretty printing and LaTeX output\n\n\n## Get started\n\nUsing `aeppl`, one can create a joint log-density graph from a graph\ncontaining Aesara `RandomVariable`s:\n\n``` python\nimport aesara\nfrom aesara import tensor as at\n\nfrom aeppl import joint_logprob, pprint\n\nsrng = at.random.RandomStream()\n\n# A simple scale mixture model\nS_rv = srng.invgamma(0.5, 0.5)\nY_rv = srng.normal(0.0, at.sqrt(S_rv))\n\n# Compute the joint log-probability\nlogprob, (y, s) = joint_logprob(Y_rv, S_rv)\n```\n\nLog-density graphs are standard Aesara graphs, so we can compute\ncompile them to compute values:\n\n``` python\nlogprob_fn = aesara.function([y, s], logprob)\n\nlogprob_fn(-0.5, 1.0)\n# array(-2.46287705)\n```\n\nAePPL provides utilities to pretty-print the log-density graphs:\n\n``` python\nfrom aeppl import pprint, latex_pprint\n\n\n# Print the original graph\nprint(pprint(Y_rv))\n# b ~ invgamma(0.5, 0.5) in R, a ~ N(0.0, sqrt(b)**2) in R\n# a\n\nprint(latex_pprint(Y_rv))\n# \\begin{equation}\n#   \\begin{gathered}\n#     b \\sim \\operatorname{invgamma}\\left(0.5, 0.5\\right)\\,  \\in \\mathbb{R}\n#     \\\\\n#     a \\sim \\operatorname{N}\\left(0.0, {\\sqrt{b}}^{2}\\right)\\,  \\in \\mathbb{R}\n#   \\end{gathered}\n#   \\\\\n#   a\n# \\end{equation}\n\n# Simplify the graph so that it's easier to read\nfrom aesara.graph.rewriting.utils import rewrite_graph\nfrom aesara.tensor.rewriting.basic import topo_constant_folding\n\n\nlogprob = rewrite_graph(logprob, custom_rewrite=topo_constant_folding)\n\n\nprint(pprint(logprob))\n# s in R, y in R\n# (switch(s \u003e= 0.0,\n#         ((-0.9189385175704956 +\n#           switch(s == 0, -inf, (-1.5 * log(s)))) - (0.5 / s)),\n#         -inf) +\n#  ((-0.9189385332046727 + (-0.5 * ((y / sqrt(s)) ** 2))) - log(sqrt(s))))\n```\n\nJoint log-densities can be computed for some terms that are *derived* from\n`RandomVariable`s, as well:\n\n``` python\n# Create a switching model from a Bernoulli distributed index\nZ_rv = srng.normal([-100, 100], 1.0, name=\"Z\")\nI_rv = srng.bernoulli(0.5, name=\"I\")\n\nM_rv = Z_rv[I_rv]\nM_rv.name = \"M\"\n\n# Compute the joint log-probability for the mixture\nlogprob, (m, z, i) = joint_logprob(M_rv, Z_rv, I_rv)\n\n\nlogprob = rewrite_graph(logprob, custom_rewrite=topo_constant_folding)\n\nprint(pprint(logprob))\n# i in Z, m in R, a in Z\n# (switch((0 \u003c= i and i \u003c= 1), -0.6931472, -inf) +\n#  ((-0.9189385332046727 + (-0.5 * (((m - [-100  100][a]) / [1. 1.][a]) ** 2))) -\n#   log([1. 1.][a])))\n```\n\nTake a look at the [documentation][documentation-examples] for more examples.\n\n\n## Install\n\nThe latest release of `aeppl` can be installed from PyPI using `pip`:\n\n``` bash\npip install aeppl\n```\n\nOr via conda-forge:\n\n``` bash\nconda install -c conda-forge aeppl\n```\n\nThe nightly (bleeding edge) version of `aeppl` can be installed using `pip`:\n\n``` bash\npip install aeppl-nightly\n```\n\n## Get help\n\nReport bugs by opening an [issue][issues]. If you have a question regarding the usage of AePPL, start a [discussion][discussions] or visit our [Discord server][discord] and [Gitter room][gitter] chats.\n\n## Contribute\n\nAePPL welcomes contributions. To start contributing, take a look at the open [issues][issues].\n\nIf you want to implement a new feature, open a [discussion][discussions] or come chat with us on [Discord][discord] or [Gitter][gitter].\n\n[contributors]: https://github.com/aesara-devs/aeppl/graphs/contributors\n[contributors-badge]: https://img.shields.io/github/contributors/aesara-devs/aeppl?style=flat-square\u0026logo=github\u0026logoColor=white\u0026color=ECEFF4\n[discussions]: https://github.com/aesara-devs/aeppl/discussions\n[documentation-examples]: https://aeppl.readthedocs.io/en/latest/examples.html\n[downloads-badge]: https://img.shields.io/pypi/dm/aeppl?style=flat-square\u0026logo=pypi\u0026logoColor=white\u0026color=8FBCBB\n[discord]: https://discord.gg/h3sjmPYuGJ\n[discord-badge]: https://img.shields.io/discord/1072170173785723041?color=81A1C1\u0026logo=discord\u0026logoColor=white\u0026style=flat-square\n[gitter]: https://gitter.im/aesara-devs/aeppl\n[gitter-badge]: https://img.shields.io/gitter/room/aesara-devs/aeppl?color=81A1C1\u0026logo=matrix\u0026logoColor=white\u0026style=flat-square\n[issues]: https://github.com/aesara-devs/aeppl/issues\n[releases]: https://github.com/aesara-devs/aeppl/releases\n[twitter]: https://twitter.com/AesaraDevs\n[twitter-badge]: https://img.shields.io/twitter/follow/AesaraDevs?style=social\n[pypi]: https://pypi.org/project/aeppl/\n[pypi-badge]: https://img.shields.io/pypi/v/aeppl?color=ECEFF4\u0026logo=python\u0026logoColor=white\u0026style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faesara-devs%2Faeppl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faesara-devs%2Faeppl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faesara-devs%2Faeppl/lists"}