Skip to content

Commit

Permalink
Support for approximate multivariate raw moments.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathf committed May 11, 2021
1 parent 6cdf4c7 commit b13537f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions 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)
==========================

Expand Down
15 changes: 12 additions & 3 deletions chaospy/distributions/approximation.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -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"]
Expand Down

0 comments on commit b13537f

Please sign in to comment.