Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytic methods #62

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

michaeldickens
Copy link
Contributor

@michaeldickens michaeldickens commented Jan 1, 2024

Implement the ability to analytically simplify common combinations of distributions, for example the sum of two normal distributions is normal and the product of two log-normal distributions is log-normal.

The analytic simplification is performed by Distribution.simplify() which calls out to a helper class FlatTree.

I also modified sq.sample() to automatically call simplify() before sampling.

This PR is most useful in conjunction with #61. Performing analytic reductions before falling back to numeric methods increases both speed and accuracy. Without support for numeric methods, analytic reduction does increase the speed of Monte Carlo sampling, but probably only by a modest constant factor (eg if half the distributions in your model can be combined analytically, it doubles the speed), and it doesn't increase accuracy at all.

This docstring lists all the simplifications that it knows how to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant