adaptive_approximate_polynomial_chaos

pyapprox.approximate.adaptive_approximate_polynomial_chaos(fun, univariate_variables, callback=None, refinement_indicator=<function variance_pce_refinement_indicator>, growth_rules=None, max_nsamples=100, tol=0, verbose=0, ncandidate_samples=10000.0, generate_candidate_samples=None)[source]

Compute an adaptive Polynomial Chaos Expansion of a function.

Parameters
funcallable

The function to be minimized

fun(z) -> np.ndarray

where z is a 2D np.ndarray with shape (nvars,nsamples) and the output is a 2D np.ndarray with shape (nsamples,nqoi)

univariate_variableslist

A list of scipy.stats random variables of size (nvars)

callbackcallable

Function called after each iteration with the signature

callback(approx_k)

where approx_k is the current approximation object.

refinement_indicatorcallable

A function that retuns an estimate of the error of a sparse grid subspace with signature

refinement_indicator(subspace_index,nnew_subspace_samples,sparse_grid) -> float, float

where subspace_index is 1D np.ndarray of size (nvars), nnew_subspace_samples is an integer specifying the number of new samples that will be added to the sparse grid by adding the subspace specified by subspace_index and sparse_grid is the current pyapprox.adaptive_sparse_grid.CombinationSparseGrid object. The two outputs are, respectively, the indicator used to control refinement of the sparse grid and the change in error from adding the current subspace. The indicator is typically but now always dependent on the error.

growth_ruleslist or callable

a list (or single callable) of growth rules with signature

growth_rule(l)->integer

where the output nsamples specifies the number of indices of the univariate basis of level l.

If the entry is a callable then the same growth rule is applied to every variable.

max_nsamplesinteger

The maximum number of evaluations of fun.

tolfloat

Tolerance for termination. The construction of the sparse grid is terminated when the estimate error in the sparse grid (determined by refinement_indicator is below tol.

verboseinteger

Controls messages printed during construction.

ncandidate_samplesinteger

The number of candidate samples used to generate the Leja sequence The Leja sequence will be a subset of these samples.

generate_candidate_samplescallable

A function that generates the candidate samples used to build the Leja sequence with signature

generate_candidate_samples(ncandidate_samples) -> np.ndarray

The output is a 2D np.ndarray with size(nvars,ncandidate_samples)

Returns
resultpyapprox.approximate.ApproximateResult

Result object with the following attributes

approxpyapprox.multivariate_polynomials.PolynomialChaosExpansion

The PCE approximation