jonathf / chaospy

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

chaospy.approximate_moment(normal, [2]) doesn't run #401

Closed dwdotson closed 1 year ago

dwdotson commented 1 year ago

Describe the bug I just found out about CHAOSPY and downloaded it using "conda install -c conda-forge chaospy" which seemed to install version 3.8. I started working on the Quick Tutorial and some of the examples didn't run. I uninstalled 3.8 and installed "pip install chaospy==4.3.9.post1" which solved some of the problems until I got to the command on the Statistical moments tutorial "chaospy.approximate_moment(normal, [2])" which gave me this error:

File ~\AppData\Local\miniconda3\Lib\site-packages\chaospy\quadrature\hypercube.py:422 in scale_quadrature assert numpy.sum(weights) <= 1 + 1e-10

AssertionError

To Reproduce Provide a minimal code example that reproduces the error

Expected behavior A clear and concise description of what you expected to happen. If an exception is raised, please provide the exception traceback.

Desktop (please complete the following information):

Additional context I'm running Python 3.10.8 and Here's the code down to the error (copied from the tutorial): import chaospy normal = chaospy.Normal(mu=2, sigma=2) normal samples = normal.sample(4, seed=1234) samples from matplotlib import pyplot pyplot.hist(normal.sample(10000, seed=1234), 30) pyplot.show() normal.sample([2, 2], seed=1234) import numpy numpy.random.seed(1234) normal.sample(4) normal.pdf([-2, 0, 2]) q_loc = numpy.linspace(-4, 8, 200) pyplot.plot(q_loc, normal.pdf(q_loc)) pyplot.show() normal.cdf([-2, 0, 2]) pyplot.plot(q_loc, normal.cdf(q_loc)) pyplot.show() normal.mom([0, 1, 2]) chaospy.approximate_moment(normal, [2])

jonathf commented 1 year ago

I've made a new relase v4.3.10. Let me know if it solves the problem.