jonathf / chaospy

Chaospy - Toolbox for performing uncertainty quantification.
https://chaospy.readthedocs.io/
MIT License
439 stars 87 forks source link

Add TruncatedNormalDistribution #250

Open lblonk opened 4 years ago

lblonk commented 4 years ago

Hi, thanks for creating this very nice library! I was wondering, would a PR adding Truncated variations of some popular distributions be welcomed? , i.e. as in https://openturns.github.io/openturns/master/examples/probabilistic_modeling/truncated_distribution.html ? Or are there reasons against this; i.e. would it not play well with some of the components in the system?

jonathf commented 4 years ago

PRs with added functionality is very much welcomed. And having truncation schemes is also something that has been useful in my work.

It might not be very well documented, but both truncated normal specifically and generic truncated distribution is already in place though. See chaospy.TruncNormal and chaospy.Trunc respectively. The former is faster and more accurate as it is optimized for the Normal distribution, while the latter can be used on any scalar or stochastically independent vector.

lblonk commented 4 years ago

Thanks for you soon reply! (and sorry for the delay in mine). Great to see Truncation is already supported! And I see there are already some very useful doc-strings in those classes.

If I wanted to add something on TruncNormal and generic truncation to the docs, would I add a link to the chaospy.TruncNormal in doc/distributions/collection.rst, and an extra bullet-point on custom trunctation in https://github.com/jonathf/chaospy/blob/master/doc/distributions/custom.rst? (I am familiar with sphinx) Thanks.

jonathf commented 4 years ago

I am currently working on moving tutorial/cookbook recipes over to Jupyter Notebooks, and adding them back to the docs using nbsphinx. The idea is that Notebooks are much easier to create and edit, it auto-generates code output, and can have much better support for plotting.

Still work in progress, but this is what I have in mind: https://chaospy.readthedocs.io/en/nbsphinx/tutorials/README.html

If you want to contribute, that would be very much appreciated.