diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0c07aa41..3faf5f4d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Master Branch ============= +Version 4.2.7 (2021-05-11) +========================== + +ADDED: + * Support for approximate multivariate raw moments. + Version 4.2.6 (2021-05-10) ========================== diff --git a/chaospy/distributions/approximation.py b/chaospy/distributions/approximation.py index e84b67a8..e09b39dd 100644 --- a/chaospy/distributions/approximation.py +++ b/chaospy/distributions/approximation.py @@ -187,11 +187,20 @@ def approximate_moment( """ assert isinstance(distribution, chaospy.Distribution) - k_loc = tuple(numpy.asarray(k_loc).tolist()) - assert len(k_loc) == len(distribution), "incorrect size of exponents" + k_loc = numpy.asarray(k_loc) + if len(distribution) > 1: + assert not distribution.stochastic_dependent, ( + "Dependent distributions does not support moment approximation.") + assert len(k_loc) == len(distribution), "incorrect size of exponents" + return numpy.prod([ + approximate_moment(distribution[idx], (k_loc[idx],), + order=order, rule=rule, **kwargs) + for idx in range(len(distribution)) + ], axis=0) + + k_loc = tuple(k_loc.tolist()) assert all([isinstance(k, int) for k in k_loc]), ( "exponents must be integers: %s found" % type(k_loc[0])) - assert len(distribution) == 1, "only 1-D distributions support approximate moment." order = int(1e5 if order is None else order) if (distribution, order) not in MOMENTS_QUADS: diff --git a/pyproject.toml b/pyproject.toml index d56d5309..bee972ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api" [tool.poetry] name = "chaospy" -version = "4.2.6" +version = "4.2.7" description = "Numerical tool for perfroming uncertainty quantification" license = "MIT" authors = ["Jonathan Feinberg"]