-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More efficient calculation of hyperbolic basis for high-dimensional inputs.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/UQpy/surrogates/polynomial_chaos/polynomials/HyperbolicBasis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Union | ||
|
||
import numpy as np | ||
|
||
from UQpy.distributions.baseclass import Distribution | ||
from UQpy.distributions.collection import JointIndependent, JointCopula | ||
from UQpy.surrogates.polynomial_chaos.polynomials.baseclass.PolynomialBasis import PolynomialBasis | ||
|
||
|
||
class HyperbolicBasis(PolynomialBasis): | ||
|
||
def __init__(self, distributions: Union[Distribution, list[Distribution]], max_degree: int, hyperbolic: float = 1): | ||
""" | ||
Create hyperbolic from total-degree polynomial basis. | ||
:param distributions: List of univariate distributions. | ||
:param max_degree: Maximum polynomial degree of the 1D chaos polynomials. | ||
:param hyperbolic: Parameter of hyperbolic truncation reducing interaction terms <0,1> | ||
""" | ||
inputs_number = 1 if not isinstance(distributions, (JointIndependent, JointCopula)) \ | ||
else len(distributions.marginals) | ||
multi_index_set = PolynomialBasis.calculate_hyperbolic_set(inputs_number=inputs_number, | ||
degree=max_degree,q=hyperbolic) | ||
if 0 < hyperbolic < 1: | ||
mask = np.round(np.sum(multi_index_set ** hyperbolic, axis=1) ** (1 / hyperbolic), 4) <= max_degree | ||
multi_index_set = multi_index_set[mask] | ||
polynomials = PolynomialBasis.construct_arbitrary_basis(inputs_number, distributions, multi_index_set) | ||
super().__init__(inputs_number, len(multi_index_set), multi_index_set, polynomials, distributions) |