jonathf / chaospy

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

PCE with TruncNormal input variables cannot be used for uncertainty quantification and sensitivity analysis #354

Open luyipin123 opened 2 years ago

luyipin123 commented 2 years ago

When TruncNormal is selected as the distribution and fitting PCE, we perform chaospy.E(approx, distribution) or chaospy.Std(approx, distribution). Finally the errors are as follow:

Traceback (most recent call last): File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\distribution.py", line 618, in mom out = [self._get_mom(kdata) for kdata in K.T] File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\distribution.py", line 618, in out = [self._get_mom(kdata) for kdata in K.T] File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\distribution.py", line 641, in _get_mom ret_val = float(self._mom(kdata, *parameters)) File "D:\Anaconda\lib\site-packages\chaospy\distributions\operators\joint.py", line 161, in _mom output = self._owners[unique_idx][1]._get_mom(kloc[index == unique_idx]) File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\distribution.py", line 641, in _get_mom ret_val = float(self._mom(kdata, parameters)) File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\shift_scale.py", line 109, in _mom for key, coeff in zip(poly.exponents, poly.coefficients)]) File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\shift_scale.py", line 109, in for key, coeff in zip(poly.exponents, poly.coefficients)]) File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\distribution.py", line 641, in _get_mom ret_val = float(self._mom(kdata, parameters)) File "D:\Anaconda\lib\site-packages\chaospy\distributions\baseclass\simple.py", line 110, in _mom "%s: does not support analytical raw moments." % self) chaospy.UnsupportedFeature: trunc_normal(lower=0, upper=1, mu=0, sigma=1): does not support analytical raw moments.

During handling of the above exception, another exception occurred:

jonathf commented 2 years ago

Do you mind reporting stats on your run. In particular:

luyipin123 commented 2 years ago

My test_run is as follow:

import chaospy as cp import numpy as np

m = 2 expansion_order = 3 level = 3

def model_solver(q): return q[0]*np.e**-q[1]+1

distribution = cp.Iid(cp.TruncNormal(0, 1), m)

abscissas, weights = cp.generate_quadrature(level, distribution, rule='gaussian')

solves = np.array([model_solver(q) for q in abscissas.T])

expansion, norms = cp.generate_expansion(expansion_order, distribution, retall=True)

approx = cp.fit_quadrature(expansion, abscissas, weights, solves, norms=norms)

expected = cp.E(approx, distribution) deviation = cp.Std(approx, distribution) First_indices = cp.Sens_m(approx, distribution) Total_indices = cp.Sens_t(approx, distribution)

从 Windows 版邮件https://go.microsoft.com/fwlink/?LinkId=550986发送

发件人: Jonathan @.> 发送时间: 2021年8月17日 16:43 收件人: @.> 抄送: @.>; @.> 主题: Re: [jonathf/chaospy] PCE with TruncNormal input variables cannot be used for uncertainty quantification and sensitivity analysis (#354)

Do you mind reporting stats on your run. In particular:

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jonathf/chaospy/issues/354#issuecomment-900109978, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVHPURHHHUVQH32D67RMN73T5IOMBANCNFSM5CJKTLNQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.

jonathf commented 2 years ago

I am unable to replicate the issue on my local machine.

To weed out a small list of subtle problems, do you mind doing the following. I don't use windows (which I assume you do from the error output), so I appologies in advance for any mistake in the recipy.

Anyways:

Let me know how it goes and if it solves the problem or not.

luyipin123 commented 2 years ago

Hello, I've followed the steps you said, but I still haven't solved the problem. I'm still prompted before the error

从 Windows 版邮件https://go.microsoft.com/fwlink/?LinkId=550986发送

发件人: Jonathan @.> 发送时间: 2021年8月18日 22:30 收件人: @.> 抄送: @.>; @.> 主题: Re: [jonathf/chaospy] PCE with TruncNormal input variables cannot be used for uncertainty quantification and sensitivity analysis (#354)

I am unable to replicate the issue on my local machine.

To weed out a small list of subtle problems, do you mind doing the following. I don't use windows (which I assume you do from the error output), so I appologies in advance for any mistake in the recipy.

Anyways:

Let me know how it goes and if it solves the problem or not.

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jonathf/chaospy/issues/354#issuecomment-901164122, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVHPURFV42GWXQVEIR6VHIDT5O7YBANCNFSM5CJKTLNQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email.

jonathf commented 2 years ago

Very weird.

Can you post the new trace stack? It shouldn't be exactly the same. The paths at least should point to a new files.