Skip to content

Commit 98371f1

Browse files
authored
Support for approximate multivariate raw moments. (#335)
1 parent 6cdf4c7 commit 98371f1

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Master Branch
22
=============
33

4+
Version 4.2.7 (2021-05-11)
5+
==========================
6+
7+
ADDED:
8+
* Support for approximate multivariate raw moments.
9+
410
Version 4.2.6 (2021-05-10)
511
==========================
612

chaospy/distributions/approximation.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,20 @@ def approximate_moment(
187187
188188
"""
189189
assert isinstance(distribution, chaospy.Distribution)
190-
k_loc = tuple(numpy.asarray(k_loc).tolist())
191-
assert len(k_loc) == len(distribution), "incorrect size of exponents"
190+
k_loc = numpy.asarray(k_loc)
191+
if len(distribution) > 1:
192+
assert not distribution.stochastic_dependent, (
193+
"Dependent distributions does not support moment approximation.")
194+
assert len(k_loc) == len(distribution), "incorrect size of exponents"
195+
return numpy.prod([
196+
approximate_moment(distribution[idx], (k_loc[idx],),
197+
order=order, rule=rule, **kwargs)
198+
for idx in range(len(distribution))
199+
], axis=0)
200+
201+
k_loc = tuple(k_loc.tolist())
192202
assert all([isinstance(k, int) for k in k_loc]), (
193203
"exponents must be integers: %s found" % type(k_loc[0]))
194-
assert len(distribution) == 1, "only 1-D distributions support approximate moment."
195204

196205
order = int(1e5 if order is None else order)
197206
if (distribution, order) not in MOMENTS_QUADS:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"
44

55
[tool.poetry]
66
name = "chaospy"
7-
version = "4.2.6"
7+
version = "4.2.7"
88
description = "Numerical tool for perfroming uncertainty quantification"
99
license = "MIT"
1010
authors = ["Jonathan Feinberg"]

0 commit comments

Comments
 (0)