tensap.approximation.bases package¶
Submodules¶
tensap.approximation.bases.full_tensor_product_functional_basis module¶
Module full_tensor_product_functional_basis.
-
class
tensap.approximation.bases.full_tensor_product_functional_basis.
FullTensorProductFunctionalBasis
(bases)¶ Bases:
tensap.approximation.bases.functional_basis.FunctionalBasis
Class FullTensorProductFunctionalBasis.
- Attributes
- baseslist or tensap.FunctionalBases
The bases associated with the object.
Methods
adaptation_path
()Return the adaptation path of the functional basis.
cardinal
()Return the number of basis functions.
conditional_expectation
(dims, *args)Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)).
domain
()Return the domain of the set of basis functions, which is the support of the associated measure.
eval
(x)Return the evaluation of the basis functions at the points x.
expectation
()Return the expectation of the basis functions.
gram_matrix
([dims])Return the gram matrix of each basis of self, or of a selection of them if dims is provided.
interpolate
(y[, x])Provide an interpolation on a functional basis of a function (or values of the function) y associated with a set of n interpolation points x.
interpolation_points
(*args)Return the interpolation points for the basis.
keep_bases
(ind)Keep only the bases of self of index ind.
kron
()Compute the Kronecker product of two bases.
length
()Return the number of bases in self.bases.
magic_points
([x, J])Provide the magic points associated with a functional basis f selected in a given set of points x.
mean
(*args)Return the mean of the basis functions.
ndim
()Return the dimension n for f defined in R^n.
Orthonormalize the basis.
plot
([indices, n])Plot the functions of the basis.
projection
(fun, I)Compute the projection of the function fun on the basis functions of self.
random
([n, measure])Evaluate the basis using n points drawn randomly according to measure if provided, or to self.measure otherwise.
remove_bases
(ind)Remove bases of self of index ind.
storage
()Return the storage requirement of the FunctionalBasis.
tensor_product_interpolation
(fun[, grid])Return the interpolation of function fun on a product grid.
transpose
(perm)Return self with the basis permutation perm.
christoffel
keep_mapping
optimal_sampling_measure
remove_mapping
-
cardinal
()¶ Return the number of basis functions.
- Returns
- int
The number of basis functions.
-
conditional_expectation
(dims, *args)¶ Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)). The expectation with respect to other variables (in the complementary set of dims) is taken with respect to the probability measure given by tensap.RandomVector XdimsC if provided, or with respect to the probability measure associated with the corresponding bases of the function.
- Parameters
- dimsnumpy.ndarray
The dimensions in which the expectation is computed.
- XdimsC: tensap.RandomVector, optional
The random vector used for the computation of the conditional expectation. The default is None, indicating to use the
- probability measure associated with the basis.
- Returns
- ftensap.FunctionalBasisArray
The conditional expectation of the function.
-
domain
()¶ Return the domain of the set of basis functions, which is the support of the associated measure.
- Returns
- numpy.ndarray
The domain of the set of basis functions
-
eval
(x)¶ Return the evaluation of the basis functions at the points x.
- Parameters
- xlist or numpy.ndarray
The points at which the basis functions are to be evaluted.
- Returns
- numpy.ndarray
The evaluations of the basis functions at the points x.
-
gram_matrix
(dims=None)¶ Return the gram matrix of each basis of self, or of a selection of them if dims is provided.
- Parameters
- dimslist or numpy.ndarray, optional
The dimensions of the bases for which the gram matrix is computed. The default is None, indicating all the bases.
- Returns
- list
The gram matrix of the selected bases.
-
interpolation_points
(*args)¶ Return the interpolation points for the basis.
See also FunctionalBasis.magic_points.
- Parameters
- *argstuple
The inputs arguments of the method FunctionalBasis.magic_points.
- Returns
- numpy.ndarray
The interpolation points for the basis.
-
keep_bases
(ind)¶ Keep only the bases of self of index ind.
- Parameters
- indint or list or numpy.ndarray
The indices of the bases to keep.
- Returns
- tensap.FullTensorProductFunctionalBasis
The FullTensorProductFunctionalBasis with kept bases.
-
keep_mapping
(ind)¶
-
length
()¶ Return the number of bases in self.bases.
- Returns
- int
The number of bases in self.bases.
-
mean
(*args)¶ Return the mean of the basis functions.
- Returns
- numpy.ndarray
The mean of the basis functions.
-
ndim
()¶ Return the dimension n for f defined in R^n.
- Returns
- int
The dimension n for f defined in R^n.
-
optimal_sampling_measure
()¶
-
orthonormalize
()¶ Orthonormalize the basis.
- Returns
- outtensap.SubFunctionalBasis
The orthonormalized basis.
-
projection
(fun, I)¶ Compute the projection of the function fun on the basis functions of self.
- Parameters
- funtensap.Function
The function to project.
- Itensap.IntegrationRule
The integration rule used to compute the projection.
- Returns
- tensap.FunctionalTensor
The projection of the function fun on the basis functions of self.
- outputdict
Dictionnary containing the number of evaluations of the function in the key ‘number_of_evaluations’.
- Raises
- NotImplementedError
If the provided integration rule is not a tensap.FullTensorProductIntegrationRule.
-
remove_bases
(ind)¶ Remove bases of self of index ind.
- Parameters
- indint or list or numpy.ndarray
The indices of the bases to remove.
- Returns
- tensap.FullTensorProductFunctionalBasis
The FullTensorProductFunctionalBasis with removed bases.
-
remove_mapping
(ind)¶
-
tensor_product_interpolation
(fun, grid=None)¶ Return the interpolation of function fun on a product grid.
- Parameters
- funfunction or tensap.Function or tensap.Tensor
The function to interpolate, or a tensor of order d whose entries are the evaluations of the function on a product grid.
- gridlist, optional
The grid of points used for the interpolation. If one grid has more points than the dimension of the corresponding basis, use magicPoints for the selection of a subset of points adapted to the basis. The default is None, indicating to use the method self.bases.interpolation_points().
- Returns
- tensap.FunctionalTensor
The interpolation of the function.
- outputdict
A dictionnary of outputs of the method.
- Raises
- ValueError
If the argument fun is neither a tensap.Function, a function nor a tensap.Tensor.
-
transpose
(perm)¶ Return self with the basis permutation perm.
- Parameters
- permlist or numpy.ndarray
The permutation of the bases.
- Returns
- tensap.FullTensorProductFunctionalBasis
The FullTensorProductFunctionalBasis with permuted bases.
tensap.approximation.bases.functional_bases module¶
Module functional_bases.
-
class
tensap.approximation.bases.functional_bases.
FunctionalBases
(bases=None)¶ Bases:
object
Class FunctionalBases.
- Attributes
- baseslist or numpy.ndarray, or tensap.FunctionalBases, optional
List or numpy.ndarray containing objects of type FunctionalBasis. The default is None.
- measuretensap.Measure
The measure associated with the functional bases. By default, a tensap.ProductMeasure constituted of the attribute measure of each basis of bases.
Methods
Compute the adaptationPath for each basis in self.
cardinals
([ind])Return the number of functions in each basis of self, or in basis ind if provided.
derivative
(n)Compute the n-derivative of the basis functions of self.
domain
()Return the domain of each basis of self.
duplicate
(basis, dim)Create a FunctionalBases with bases created with a duplication of basis d times.
eval
(x[, dims, nargout])Computes evaluations of the basis functions of self at points x in dimensions dims if provided, in all the dimensions if not.
eval_derivative
(n, x[, dims, nargout])Compute evaluations of the n-derivative of the basis functions of
Returns the random vector associated with self.
gram_matrix
([dims])Return the gram matrix of each basis of self, or of a selection of them if dims is provided.
interpolation_points
([x])Return the interpolation points for the bases.
keep_bases
(ind)Keep only the bases of self of index ind.
kron
(g)Return the bases obtained by the Kronecker product of two bases.
length
()Return the number of bases in self.
magic_points
(x[, J])Provide the magic points associated with the functional bases selected in a given set of points x.
mean
([dims, measure])Compute the mean of self in the dimensions in dims according to the RandomVector measure if provided, or to the standard RandomVector associated with each basis if not.
ndim
()Return the dimension of each basis of self.
one
([dims])Return the coefficients associated with the FunctionalBases so that it returns one.
Orthonormalize the basis functions of self.
random
(*args, **kwargs)Compute random evaluations of the bases in self.
random_dims
(dims[, n, measure, nargout])Evaluate the bases in dimensions dims of the bases of self using n points drawn randomly according to measure if provided, or to self.measure.marginal(dims) otherwise.
remove_bases
(ind)Remove bases of self of index ind.
storage
()Return the storage requirement of the FunctionalBases.
tensor_product_interpolation
(*args)Interpolate a function on a product grid.
transpose
(perm)Return self with the basis permutation perm.
-
adaptation_path
()¶ Compute the adaptationPath for each basis in self.
See also tensap.FunctionalBasis.adaptation_path.
- Returns
- list
List of adaptation paths for each basis.
-
cardinals
(ind=None)¶ Return the number of functions in each basis of self, or in basis ind if provided.
- Parameters
- indind, optional
The index of the selected basis. The default is None.
- Returns
- numpy.ndarray
The number of functions in each basis of self, or in basis ind if provided.
-
derivative
(n)¶ Compute the n-derivative of the basis functions of self.
- Parameters
- nlist or numpy.ndarray
The order of derivation in each dimension.
- Returns
- outFunctionalBases
A Functionalbases with the n-derivative of the basis functions of self.
-
domain
()¶ Return the domain of each basis of self.
- Returns
- list
The domain of each basis of self.
-
static
duplicate
(basis, dim)¶ Create a FunctionalBases with bases created with a duplication of basis d times.
- Parameters
- basistensap.FunctionalBasis
The basis to be duplicated.
- dimint
The number of times basis is duplicated.
- Returns
- tensap.FunctionalBases
The obtained FunctionalBases.
-
eval
(x, dims=None, nargout=1)¶ Computes evaluations of the basis functions of self at points x in dimensions dims if provided, in all the dimensions if not.
- Parameters
- xnumpy.ndarray
The input points.
- dimslist or numpy.ndarray, optional
The dimensions of the bases to be evaluated. The default is None, indicating all the dimensions.
- nargoutint, optional
Indicates the number of expected outputs. The default is 1, indicating to return only the evaluations of the basis functions.
- Returns
- outlist
Evaluations of the basis functions of self.
- xnumpy.ndarray
The input points, grouped by basis.
-
eval_derivative
(n, x, dims=None, nargout=1)¶ Compute evaluations of the n-derivative of the basis functions of self at points x in each dimension in dims if provided, in all the dimensions otherwise.
- Parameters
- nlist or numpy.ndarray
The order of derivation in each dimension (in dims if provided).
- xnumpy.ndarray
The input points.
- dimslist or numpy.ndarray, optional
The dimensions of the bases for which the n-derivative is to be computed. The default is None, indicating all the dimensions.
- nargoutint, optional
Indicates the number of expected outputs. The default is 1, indicating to return only the evaluations of the n-derivative of the basis functions.
- Returns
- outlist
Evaluations of the n-derivative of the basis functions of self.
- xnumpy.ndarray
The input points, grouped by basis.
-
get_random_vector
()¶ Returns the random vector associated with self.
- Returns
- measuretensap.RandomVector
The random vector associated with self.
-
gram_matrix
(dims=None)¶ Return the gram matrix of each basis of self, or of a selection of them if dims is provided.
- Parameters
- dimslist or numpy.ndarray, optional
The dimensions of the bases for which the gram matrix is computed. The default is None, indicating all the bases.
- Returns
- list
The gram matrix of the selected bases.
-
interpolation_points
(x=None)¶ Return the interpolation points for the bases.
- Parameters
- xtensap.FullTensorGrid or list or numpy.ndarray
The set of points in which the interpolation points are selected.
- Returns
- pointslist
The interpolation points.
-
keep_bases
(ind)¶ Keep only the bases of self of index ind.
- Parameters
- indint or list or numpy.ndarray
The indices of the bases to keep.
- Returns
- outtensap.FunctionalBases
The FunctionalBases with kept bases.
-
kron
(g)¶ Return the bases obtained by the Kronecker product of two bases.
- Parameters
- gFunctionalBases
The second bases of the product.
- Returns
- outFunctionalBases
The bases obtained by the Kronecker product of two bases.
-
length
()¶ Return the number of bases in self.
- Returns
- int
The number of bases in self.
-
magic_points
(x, J=None)¶ Provide the magic points associated with the functional bases selected in a given set of points x.
- Parameters
- xtensap.FullTensorGrid or list or numpy.ndarray
The set of points in which the magic points are selected.
- Jnumpy.ndarray, optional
The default is None. If not none, selected the magic indices with tensap.magic_indices(F[:, J], self.cardinal(), ‘left’)[0]
- Returns
- pointslist
The magic points associated with each basis of self.
- indlist
The locations of the magic points in x for each basis of self.
-
mean
(dims=None, measure=None)¶ Compute the mean of self in the dimensions in dims according to the RandomVector measure if provided, or to the standard RandomVector associated with each basis if not.
- Parameters
- dimslist or numpy.ndarray, optional
The dimensions of the bases for which the mean is to be computed. The default is None, indicating all the bases.
- measuretensap.RandomVector or tensap.RandomVariable, optional
The probability measure according to which the mean is computed. The default is None, indicating to use the self.measure.
- Returns
- outlist
The mean of each basis functions.
-
ndim
()¶ Return the dimension of each basis of self.
- Returns
- list
The dimension of each basis of self.
-
one
(dims=None)¶ Return the coefficients associated with the FunctionalBases so that it returns one.
- Parameters
- dimslist or numpy.ndarray, optional
The dimensions of the bases that need to return one. The default is None, indicating all the bases.
- Returns
- list
The list of coefficients so that the selected bases return one.
-
orthonormalize
()¶ Orthonormalize the basis functions of self.
- Returns
- tensap.FunctionalBases
The FunctionalBases with orthonormalized basis functions.
-
random
(*args, **kwargs)¶ Compute random evaluations of the bases in self.
- Parameters
- *argsmisc
Additional parameters for the random generation. See random_dims.
- Returns
- list or numpy.ndarray
Random evaluations of the basis functions of self.
- numpy.ndarray
The input points, grouped by basis.
-
random_dims
(dims, n=1, measure=None, nargout=1)¶ Evaluate the bases in dimensions dims of the bases of self using n points drawn randomly according to measure if provided, or to self.measure.marginal(dims) otherwise.
- Parameters
- dimslist or numpy.ndarray
The dimensions of the bases to be evaluated.
- nint, optional
The number of random evaluations. The default is 1.
- measuretensap.ProbabilityMeasure, optional
The probability measure used for the generation of the input points. The default is None, indicating to use self.measure.marginal(dims).
- Returns
- bases_evallist or numpy.ndarray
Random evaluations of the basis functions of self.
- xnumpy.ndarray
The input points, grouped by basis.
-
remove_bases
(ind)¶ Remove bases of self of index ind.
- Parameters
- indint or list or numpy.ndarray
The indices of the bases to remove.
- Returns
- outtensap.FunctionalBases
The FunctionalBases with removed bases.
-
storage
()¶ Return the storage requirement of the FunctionalBases.
- Returns
- int
The storage requirement of the FunctionalBases.
-
tensor_product_interpolation
(*args)¶ Interpolate a function on a product grid.
See also tensap.FullTensorProductFunctionalBasis.tensorProductInterpolation.
- Parameters
- *argstuple
Parameters of the method tensorProductInterpolation of tensap.FullTensorProductFunctionalBasis.
- Returns
- tensap.FunctionalTensor
The interpolation of the function on a product grid.
-
transpose
(perm)¶ Return self with the basis permutation perm.
- Parameters
- permlist or numpy.ndarray
The permutation of the bases.
- Returns
- outtensap.FunctionalBases
The FunctionalBases with permuted bases.
tensap.approximation.bases.functional_basis module¶
Module functional_basis.
-
class
tensap.approximation.bases.functional_basis.
FunctionalBasis
¶ Bases:
object
Class FunctionalBasis.
- Attributes
- measuretensap.Measure
The measure associated with the FunctionalBasis.
- is_orthonormalbool
Indicates if the basis is orthonormal with respect to the associated measure.
Methods
Return the adaptation path of the functional basis.
cardinal
()Return the number of basis functions.
Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)).
domain
()Return the domain of the set of basis functions, which is the support of the associated measure.
eval
(x)Return the evaluation of the basis functions at the points x.
Return the expectation of the basis functions.
interpolate
(y[, x])Provide an interpolation on a functional basis of a function (or values of the function) y associated with a set of n interpolation points x.
interpolation_points
(*args)Return the interpolation points for the basis.
kron
()Compute the Kronecker product of two bases.
magic_points
([x, J])Provide the magic points associated with a functional basis f selected in a given set of points x.
mean
()Return the mean of the basis functions.
ndim
()Return the dimension n for f defined in R^n.
Orthonormalize the basis.
plot
([indices, n])Plot the functions of the basis.
projection
(fun, G)Compute the projection of the function fun onto the functional basis using the integration rule G.
random
([n, measure])Evaluate the basis using n points drawn randomly according to measure if provided, or to self.measure otherwise.
storage
()Return the storage requirement of the FunctionalBasis.
christoffel
optimal_sampling_measure
-
adaptation_path
()¶ Return the adaptation path of the functional basis.
- Returns
- numpy.ndarray
Boolean array, where n is the dimension of the functional basis, and m is the number of elements in the adaptation path, column P[:,i] corresponds to a sparsity pattern.
-
abstract
cardinal
()¶ Return the number of basis functions.
- Returns
- int
The number of basis functions.
-
christoffel
(x)¶
-
static
conditional_expectation
()¶ Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)). The expectation with respect to other variables (in the complementary set of dims) is taken with respect to the probability measure given by tensap.RandomVector XdimsC if provided, or with respect to the probability measure associated with the corresponding bases of the function.
- Parameters
- dimsnumpy.ndarray
The dimensions in which the expectation is computed.
- XdimsC: tensap.RandomVector, optional
The random vector used for the computation of the conditional expectation. The default is None, indicating to use the
- probability measure associated with the basis.
- Returns
- ftensap.FunctionalBasisArray
The conditional expectation of the function.
-
domain
()¶ Return the domain of the set of basis functions, which is the support of the associated measure.
- Returns
- numpy.ndarray
The domain of the set of basis functions
-
abstract
eval
(x)¶ Return the evaluation of the basis functions at the points x.
- Parameters
- xlist or numpy.ndarray
The points at which the basis functions are to be evaluted.
- Returns
- numpy.ndarray
The evaluations of the basis functions at the points x.
-
expectation
()¶ Return the expectation of the basis functions. Equivalent to self.mean().
- Returns
- numpy.ndarray
The expectation of the basis functions.
-
interpolate
(y, x=None)¶ Provide an interpolation on a functional basis of a function (or values of the function) y associated with a set of n interpolation points x.
- Parameters
- yfunction or list or numpy.ndarray
The function to interpolate, or values of it.
- xlist or numpy.ndarray, optional
The interpolation points. The default is None, indicating to deduce them from the basis.
- Returns
- ftensap.FunctionalBasisArray
The computed interpolation.
-
interpolation_points
(*args)¶ Return the interpolation points for the basis.
See also FunctionalBasis.magic_points.
- Parameters
- *argstuple
The inputs arguments of the method FunctionalBasis.magic_points.
- Returns
- numpy.ndarray
The interpolation points for the basis.
-
static
kron
()¶ Compute the Kronecker product of two bases. For two functional bases f_i, i = 1, …, n and g_j, j = 1, …, m, return a functional basis h_k, k = 1, …, nm.
- Returns
- tensap.FunctionalBasis
The obtained basis.
-
magic_points
(x=None, J=None)¶ Provide the magic points associated with a functional basis f selected in a given set of points x.
The method uses magicIndices(F,numel(f)) on the matrix F of evaluations of f at points x.
- Parameters
- xlist or numpy.ndarray, optional
The points used to construct the matrix F. The default is None, indicating to choose x automatically based on self.measure.
- Jnumpy.ndarray, optional
The default is None. If not none, selected the magic indices with tensap.magic_indices(F[:, J], self.cardinal(), ‘left’)[0]
- Returns
- pointsnumpy.ndarray
The magic points.
- indnumpy.ndarray
The locations of the magic points in x.
- outputdict
A dictionnary of outputs of the method.
-
static
mean
()¶ Return the mean of the basis functions.
- Returns
- numpy.ndarray
The mean of the basis functions.
-
abstract
ndim
()¶ Return the dimension n for f defined in R^n.
- Returns
- int
The dimension n for f defined in R^n.
-
optimal_sampling_measure
()¶
-
orthonormalize
()¶ Orthonormalize the basis.
- Returns
- outtensap.SubFunctionalBasis
The orthonormalized basis.
-
plot
(indices=None, n=10000, *args)¶ Plot the functions of the basis.
- Parameters
- indiceslist or numpy.ndarray, optional
Indices of the functions to be plotted. The default is None, indicating all the functions.
- nint, optional
The number of points used for the plot. The default is 10000.
- *argstuple
Additional parameters used by matplotlib.pyplot’s function plot.
- Returns
- None.
-
projection
(fun, G)¶ Compute the projection of the function fun onto the functional basis using the integration rule G.
- Parameters
- funfunction or tensap.Function
The function to project.
- Gtensap.IntegrationRule
The integration rule used for the projection.
- Returns
- tensap.FunctionalBasisArray
The projection of the function fun onto the functional basis using the integration rule G.
-
random
(n=1, measure=None)¶ Evaluate the basis using n points drawn randomly according to measure if provided, or to self.measure otherwise.
- Parameters
- nint, optional
The number of random evaluations. The default is 1.
- measuretensap.ProbabilityMeasure, optional
The probability measure used for the generation of the input points. The default is None, indicating to use self.measure.
- Returns
- basis_evalnumpy.ndarray
Random evaluations of the basis functions.
- xnumpy.ndarray
The input points.
-
static
storage
()¶ Return the storage requirement of the FunctionalBasis.
- Returns
- int
The storage requirement of the FunctionalBasis.
tensap.approximation.bases.functional_basis_array module¶
Module functional_basis_array.
-
class
tensap.approximation.bases.functional_basis_array.
FunctionalBasisArray
(data=None, basis=None, shape=None)¶ Bases:
tensap.functions.function.Function
Class FunctionalBasisArray.
- Attributes
- datanumpy.ndarray, optional
The coefficents of the function on the basis. The default is None.
- basistensap.FunctionalBasis, optional
The basis. The default is None.
- shapelist or numpy.ndarray, optional
Array such that the function is with values in R^(shape[0] x shape[1] x …). The default is 1.
Methods
__call__
(x[, return_f])Call self as a function.
conditional_expectation
(dims, *args)Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)).
derivative
(n)Compute the n-derivative of the function.
dot
(g[, dim])Compute the dot product between the arrays self.data and g.data treated as collections of vectors.
dot_product_expectation
(g[, dims, measure])Compute the expectation of self(X)g(X), where X is the probability measure associated with the underlying basis, or measure if provided.
eval
(x, *args)Evaluate the function at the points x.
eval_derivative
(n, x)Compute the n-derivative of the function at points x in R^d, with n a multi-index of size d.
eval_on_tensor_grid
(x)Evaluate the Function on a grid x.
Compute the evaluations of the function using the evaluations of the basis H.
expectation
([measure])Compute the expectation of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
fplot
([support, n_points])Plot the function on a support using a given number of points.
Return the coefficients of the object.
Return the random vector associated with the basis functions of the object.
Determine if the object is random.
matdiv
(v)Compute the matrix multiplication of self.data with the inverse of v.
matmul
(v)Compute the matrix multiplication of self.data with v.
mean
([measure])Compute the expectation of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
norm
([p])Compute the p-norm of the array self.data.
norm_expectation
([measure])Compute the L^2 norm of self(measure).
partial_evaluation
(not_alpha, x_not_alpha)Return the partial evaluation of a function f(x) = f(x_alpha,x_not_alpha), a function f_alpha(.) = f(., x_not_alpha) for fixed values x_not_alpha of the variables with indices not_alpha.
projection
(basis[, indices])Projection of the object on a functional basis using multi-indices indices if provided, or the multi-indices associated with the functional basis if not.
random
([n, measure])Compute evaluations of the function at an array of points of size n, drawn randomly according to the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
The storage complexity of the object, taking into account the sparsity.
std
(*args)Compute the standard deviation of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
storage
()The storage complexity of the object.
store_eval
(x)Evaluate the function, reuising previous evaluations if possible, and storing the new evaluations in self.
Converts the FunctionalBasisArray into a tensap.SubFunctionalbasis.
surf
([n])Surface plot of the bivariate function.
test_error
(g[, n, measure])Compute the test error associated with the function, using a function g or some of its evaluations as a reference.
variance
([measure])Compute the variance of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
Compute the variance of the conditional expectation of the function in dimensions in alpha.
-
conditional_expectation
(dims, *args)¶ Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)). The expectation with respect to other variables (in the complementary set of dims) is taken with respect to the probability measure given by tensap.RandomVector XdimsC if provided, or with respect to the probability measure associated with the corresponding bases of the function.
- Parameters
- dimsnumpy.ndarray
The dimensions in which the expectation is computed.
- *argstuple
Additional parameters. See also the method conditional_expectation of the underlying basis.
- Returns
- ftensap.FunctionalBasisArray
The conditional expectation of the function.
-
derivative
(n)¶ Compute the n-derivative of the function.
- Parameters
- nint
The derivation order.
- Returns
- dftensap.FunctionalBasisArray()
The n-derivative of the function.
-
dot
(g, dim=None)¶ Compute the dot product between the arrays self.data and g.data treated as collections of vectors. The function calculates the dot product of corresponding vectors along the first array dimension whose size does not equal 1.
- Parameters
- gtensap.FunctionalBasisArray
The second object of the dot product.
- dimint or list or numpy.ndarray, optional
The dimension along which the dot product is computed. The default is None, indicating all the dimensions.
- Returns
- float or numpy.ndarray
The result of the dot product.
-
dot_product_expectation
(g, dims=None, measure=None)¶ Compute the expectation of self(X)g(X), where X is the probability measure associated with the underlying basis, or measure if provided.
For vector-valued functions of X, dims specifies the dimensions of self and g corresponding to the RandomVector measure.
- Parameters
- gtensap.FunctionalBasisArray
The second function of the product.
- dimslist or numpy.ndarray, optional
The dimensions of self and g corresponding to the RandomVector measure. The default is None.
- measuretensap.ProbabilityMeasure, optional
The probability measure used for the computation of the expectation. The default is None, indicating to use the probability measure associated with the underlying basis.
- Returns
- float or numpy.ndarray
The result of the dot product.
- Raises
- NotImplementedError
If the method is not implemented.
-
eval
(x, *args)¶ Evaluate the function at the points x.
- Parameters
- xlist or numpy.ndarray
The points at which the function is to be evaluated.
- Returns
- numpy.ndarray
The evaluations of the function at the points x.
-
eval_derivative
(n, x)¶ Compute the n-derivative of the function at points x in R^d, with n a multi-index of size d.
- Parameters
- nint or list or numpy.ndarray
The derivation order in all the dimensions, or the derivation orders for each dimension.
- xnumpy.ndarray
The points used for the evaluation of the derivative.
- Returns
- numpy.ndarray
The evaluation of the n-derivative of the function at the points x.
- Raises
- NotImplementedError
If the method is not implemented for the basis.
-
eval_with_bases_evals
(H)¶ Compute the evaluations of the function using the evaluations of the basis H.
- Parameters
- Hnumpy.ndarray
The evaluations of the basis.
- Returns
- numpy.ndarray
The evaluations of the function.
-
expectation
(measure=None)¶ Compute the expectation of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
- Parameters
- measuretensap.ProbabilityMeasure, optional
The probability measure used for the computation of the expectation. The default is None, indicating to use the standard tensap.ProbabilityMeasure associated with each polynomial.
- Returns
- numpy.ndarray
The expectation of the function.
-
get_coefficients
()¶ Return the coefficients of the object.
- Returns
- numpy.ndarray
The coefficients of the object.
-
get_random_vector
()¶ Return the random vector associated with the basis functions of the object.
- Returns
- tensap.RandomVector
The random vector associated with the basis functions of the object.
-
static
is_random
()¶ Determine if the object is random.
- Returns
- bool
Boolean equal to True if the object is random.
-
matdiv
(v)¶ Compute the matrix multiplication of self.data with the inverse of v.
- Parameters
- vnumpy.ndarray
The array used in the matrix multiplication.
- Returns
- tensap.FunctionalBasisArray
The result of the matrix multiplication.
-
matmul
(v)¶ Compute the matrix multiplication of self.data with v.
- Parameters
- vnumpy.ndarray
The array used in the matrix multiplication.
- Returns
- tensap.FunctionalBasisArray
The result of the matrix multiplication.
-
mean
(measure=None)¶ Compute the expectation of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
- Parameters
- measuretensap.ProbabilityMeasure, optional
The probability measure used for the computation of the expectation. The default is None, indicating to use the standard tensap.ProbabilityMeasure associated with each polynomial.
- Returns
- numpy.ndarray
The expectation of the function.
-
norm
(p='fro')¶ Compute the p-norm of the array self.data.
See also numpy.linalg.norm.
- Parameters
- pint or numpy.inf or -numpy.inf or string, optional
The order of the norm. The default is ‘fro’.
- Returns
- float
The norm of self.data.
-
norm_expectation
(measure=None)¶ Compute the L^2 norm of self(measure). If measure is not provided, use the probability measure associated with the underlying basis of self.
- Parameters
- measuretap.ProbabilityMeasure, optional
DESCRIPTION. The default is None.
- Returns
- float
The L2 norm of the function.
-
projection
(basis, indices=None)¶ Projection of the object on a functional basis using multi-indices indices if provided, or the multi-indices associated with the functional basis if not.
- Parameters
- basistensap.FunctionalBasis (tensap.FullTensorProductFunctionalBasis
or tensap.SparseTensorProductFunctionalBasis) The basis used for the projection.
- indicestensap.MultiIndices, optional
The multi-indices used for the projection. The default is None, indicating to use basis.indices.
- Returns
- gFunctionalBasisArray
The obtained projection.
-
random
(n=1, measure=None)¶ Compute evaluations of the function at an array of points of size n, drawn randomly according to the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
- Parameters
- nint, optional
The number of random evaluations. The default is 1.
- measuretensap.ProbabilityMeasure, optional
The probability measure used to draw the points of evaluation. The default is None, indicating to use the standard tensap.ProbabilityMeasure associated with each polynomial.
- Returns
- numpy.ndarray
The random evaluations of the function.
- numpy.ndarray
The points used for the evaluations of the function.
-
sparse_storage
()¶ The storage complexity of the object, taking into account the sparsity.
- Returns
- int
The storage complexity of the object, taking into account the sparsity.
-
std
(*args)¶ Compute the standard deviation of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
- Parameters
- measuretensap.ProbabilityMeasure, optional
The probability measure used for the computation of the standard deviation. The default is None, indicating to use the standard tensap.ProbabilityMeasure associated with each polynomial.
- Returns
- numpy.ndarray
The standard deviation of the function.
-
storage
()¶ The storage complexity of the object.
- Returns
- int
The storage complexity of the object.
-
sub_functional_basis
()¶ Converts the FunctionalBasisArray into a tensap.SubFunctionalbasis.
- Returns
- tensap.SubFunctionalbasis
The FunctionalBasisArray as a tensap.SubFunctionalbasis.
-
variance
(measure=None)¶ Compute the variance of the function, according to the measure associated with the tensap.ProbabilityMeasure measure if provided, or to the standard tensap.ProbabilityMeasure associated with each polynomial if not.
- Parameters
- measuretensap.ProbabilityMeasure, optional
The probability measure used for the computation of the variance. The default is None, indicating to use the standard tensap.ProbabilityMeasure associated with each polynomial.
- Returns
- numpy.ndarray
The variance of the function.
-
variance_conditional_expectation
(alpha)¶ Compute the variance of the conditional expectation of the function in dimensions in alpha.
- Parameters
- alphanumpy.ndarray
The dimensions in which the variance of the conditional expectation of the function if computed.
- Returns
- numpy.ndarray
The variance of the conditional expectation of the function.
tensap.approximation.bases.polynomial_functional_basis module¶
Module polynomial_functional_basis.
-
class
tensap.approximation.bases.polynomial_functional_basis.
PolynomialFunctionalBasis
(basis, indices)¶ Bases:
tensap.approximation.bases.functional_basis.FunctionalBasis
Class PolynomialFunctionalBasis.
- Attributes
- basistensap.UnivariatePolynomials
The polynomials associated with the basis.
- indiceslist or numpy.ndarray
The indices of the selected polynomials.
- measuretensap.Measure
The measure associated with basis.
- is_orthonormalbool
Boolean equal to true, indicating that the basis is orthonormal with respect to measure.
Methods
adaptation_path
()Return the adaptation path of the functional basis.
cardinal
()Return the number of basis functions.
conditional_expectation
()Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)).
derivative
(k[, measure])Compute the k-th order derivative of the functions of the basis projected on itself.
domain
()Return the domain of the set of basis functions, which is the support of the associated measure.
eval
(x)Evaluate the polynomials of self.basis of degrees in self.indices at points x.
eval_derivative
(k, x)Evaluate the k-th order derivative of the functions of the basis at the points x.
expectation
()Return the expectation of the basis functions.
gradient
([measure])Compute the first order derivative of the functions of the basis projected on itself.
gram_matrix
([measure])Compute the Gram matrix of the basis.
hessian
(measure)Compute the second order derivative of the functions of the basis projected on itself.
interpolate
(y[, x])Provide an interpolation on a functional basis of a function (or values of the function) y associated with a set of n interpolation points x.
interpolation_points
(*args)Return the interpolation points for the basis.
kron
(q)Compute the Kronecker product of two bases.
magic_points
([x, J])Provide the magic points associated with a functional basis f selected in a given set of points x.
mean
([measure])Return the expectation of the basis functions, accorging to measure if provided, and to self.measure ortherwise.
ndim
()Return the dimension n for f defined in R^n.
one
()Return the coefficients associated with the basis so that it returns one.
orthonormalize
()Orthonormalize the basis.
plot
([indices, n])Plot the functions of the basis.
projection
(fun, G)Compute the projection of the function fun onto the functional basis using the integration rule G.
random
([n, measure])Evaluate the basis using n points drawn randomly according to measure if provided, or to self.measure otherwise.
Return the tensap.RandomVariable associated with self if it exists.
storage
()Return the storage requirement of the FunctionalBasis.
christoffel
optimal_sampling_measure
-
cardinal
()¶ Return the number of basis functions.
- Returns
- int
The number of basis functions.
-
christoffel
()¶
-
derivative
(k, measure=None)¶ Compute the k-th order derivative of the functions of the basis projected on itself.
- Parameters
- kint
The order of the derivative.
- measuretensap.Measure, optional
The measure used fot the projection. The default is None, indicating to use self.measure if it is a tensap.RandomVariable.
- Returns
- tensap.SubFunctionalBasis
The k-th order derivative of the functions of the basis projected on itself.
- Raises
- ValueError
If no Measure is provided or can be extracted from self.
-
domain
()¶ Return the domain of the set of basis functions, which is the support of the associated measure.
- Returns
- numpy.ndarray
The domain of the set of basis functions
-
eval
(x)¶ Evaluate the polynomials of self.basis of degrees in self.indices at points x.
- Parameters
- xlist or numpy.ndarray
The points at which the basis functions are to be evaluated.
- Returns
- numpy.ndarray
The evaluations of the polynomials of self.basis of degrees in self.indices at points x.
-
eval_derivative
(k, x)¶ Evaluate the k-th order derivative of the functions of the basis at the points x.
- Parameters
- kint
The order of the derivative.
- xlist or numpy.ndarray
The points at which the k-th derivative of the basis functions are to be evaluated.
- Returns
- numpy.ndarray
The evaluations of the k-th derivative of the polynomials of self.basis of degrees in self.indices at points x.
-
gradient
(measure=None)¶ Compute the first order derivative of the functions of the basis projected on itself.
- Parameters
- measuretensap.Measure, optional
The measure used fot the projection. The default is None, indicating to use self.measure if it is a tensap.RandomVariable.
- Returns
- tensap.SubFunctionalBasis
- The first order derivative of the functions of the basis projected
on itself.
-
gram_matrix
(measure=None)¶ Compute the Gram matrix of the basis. The Gram matrix is the matrix of the dot products between each possible couple of basis functions. The dot product in the dimension i is computed according to measure if provided, or according to self.measure otherwise.
- Parameters
- measuretensap.Measure, optional
The measure according to which the dot product is computed. The default is None, indicating to use self.measure.
- Returns
- numpy.ndarray
The Gram matrix of the basis.
- Raises
- NotImplementedError
If the attribute basis of self does not have a method moment.
-
hessian
(measure)¶ Compute the second order derivative of the functions of the basis projected on itself.
- Parameters
- measuretensap.Measure, optional
The measure used fot the projection. The default is None, indicating to use self.measure if it is a tensap.RandomVariable.
- Returns
- tensap.SubFunctionalBasis
- The second order derivative of the functions of the basis projected
on itself.
-
kron
(q)¶ Compute the Kronecker product of two bases. For two functional bases f_i, i = 1, …, n and g_j, j = 1, …, m, return a functional basis h_k, k = 1, …, nm.
- Returns
- tensap.FunctionalBasis
The obtained basis.
-
mean
(measure=None)¶ Return the expectation of the basis functions, accorging to measure if provided, and to self.measure ortherwise.
- Parameters
- measureNone or tensap.RandomVariable, optional
The measure according to which the mean is computed. The default is None, indicating to use self.measure.
- Returns
- numpy.ndarray
The mean of the basis functions.
-
ndim
()¶ Return the dimension n for f defined in R^n.
- Returns
- int
The dimension n for f defined in R^n.
-
one
()¶ Return the coefficients associated with the basis so that it returns one.
- Returns
- list
The list of coefficients so that the basis returns one.
-
optimal_sampling_measure
()¶
-
random_variable
()¶ Return the tensap.RandomVariable associated with self if it exists.
- Returns
- outtensap.RandomVariable or []
The tensap.RandomVariable associated with self if it exists, and [] otherwise.
tensap.approximation.bases.sparse_tensor_product_functional_basis module¶
Module sparse_tensor_product_functional_basis.
-
class
tensap.approximation.bases.sparse_tensor_product_functional_basis.
SparseTensorProductFunctionalBasis
(bases, indices)¶ Bases:
tensap.approximation.bases.functional_basis.FunctionalBasis
Class SparseTensorProductFunctionalBasis.
- Attributes
- baseslist or tensap.FunctionalBases
The bases associated with the object.
- indicestensap.MultiIndices
The indices of the basis functions (the indices start at 0).
Methods
adaptation_path
([p])Create an adaptation path associated with increasing p-norm of multi-indices.
cardinal
()Return the number of basis functions.
conditional_expectation
(dims, *args)Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)).
domain
()Return the domain of the set of basis functions, which is the support of the associated measure.
eval
(x)Return the evaluation of the basis functions at the points x.
expectation
()Return the expectation of the basis functions.
Return the random vector associated with the basis functions of self.
Return the gram matrix of the basis.
interpolate
(y[, x])Provide an interpolation on a functional basis of a function (or values of the function) y associated with a set of n interpolation points x.
interpolation_points
(*args)Return the interpolation points for the basis.
keep_bases
(ind)Keep only the bases of self of index ind.
kron
()Compute the Kronecker product of two bases.
length
()Return the number of bases in self.bases.
magic_points
([x, J])Provide the magic points associated with a functional basis f selected in a given set of points x.
mean
(*args)Return the mean of the basis functions.
ndim
()Return the dimension n for f defined in R^n.
orthonormalize
()Orthonormalize the basis.
plot
([indices, n])Plot the functions of the basis.
plot_multi_indices
(*args)PLot the multi-index set of the object.
projection
(fun, G)Compute the projection of the function fun onto the functional basis using the integration rule G.
random
([n, measure])Evaluate the basis using n points drawn randomly according to measure if provided, or to self.measure otherwise.
remove_bases
(ind)Remove bases of self of index ind.
storage
()Return the storage requirement of the FunctionalBasis.
tensor_product_interpolation
(fun, *args)Return the interpolation of function fun on a sparse grid.
transpose
(perm)Return self with the basis permutation perm.
christoffel
derivative
eval_derivative
eval_with_functional_bases_evals
keep_mapping
optimal_sampling_measure
remove_mapping
-
adaptation_path
(p=1)¶ Create an adaptation path associated with increasing p-norm of multi-indices.
- Parameters
- pfloat, optional
The positive real scalar p of the p-norm. The default is 1.
- Returns
- Pnumpy.ndarray
The adaptation path.
-
cardinal
()¶ Return the number of basis functions.
- Returns
- int
The number of basis functions.
-
conditional_expectation
(dims, *args)¶ Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)). The expectation with respect to other variables (in the complementary set of dims) is taken with respect to the probability measure given by tensap.RandomVector XdimsC if provided, or with respect to the probability measure associated with the corresponding bases of the function.
- Parameters
- dimsnumpy.ndarray
The dimensions in which the expectation is computed.
- XdimsC: tensap.RandomVector, optional
The random vector used for the computation of the conditional expectation. The default is None, indicating to use the
- probability measure associated with the basis.
- Returns
- ftensap.FunctionalBasisArray
The conditional expectation of the function.
-
derivative
(n)¶
-
domain
()¶ Return the domain of the set of basis functions, which is the support of the associated measure.
- Returns
- numpy.ndarray
The domain of the set of basis functions
-
eval
(x)¶ Return the evaluation of the basis functions at the points x.
- Parameters
- xlist or numpy.ndarray
The points at which the basis functions are to be evaluted.
- Returns
- numpy.ndarray
The evaluations of the basis functions at the points x.
-
eval_derivative
(n, x)¶
-
eval_with_functional_bases_evals
(Hx)¶
-
get_random_vector
()¶ Return the random vector associated with the basis functions of self.
- Returns
- tensap.RandomVector
The random vector associated with the basis functions of self.
-
gram_matrix
()¶ Return the gram matrix of the basis.
- Returns
- numpy.ndarray
The gram matrix of the basis.
-
keep_bases
(ind)¶ Keep only the bases of self of index ind.
- Parameters
- indint or list or numpy.ndarray
The indices of the bases to keep.
- Returns
- tensap.SparseTensorProductFunctionalBasis
The SparseTensorProductFunctionalBasis with kept bases.
-
keep_mapping
(ind)¶
-
length
()¶ Return the number of bases in self.bases.
- Returns
- int
The number of bases in self.bases.
-
mean
(*args)¶ Return the mean of the basis functions.
- Returns
- numpy.ndarray
The mean of the basis functions.
-
ndim
()¶ Return the dimension n for f defined in R^n.
- Returns
- int
The dimension n for f defined in R^n.
-
plot_multi_indices
(*args)¶ PLot the multi-index set of the object.
See also tensap.MultiIndices.plot.
- Parameters
- *argstuple
Additional parameters for tensap.MultiIndices’ plot method.
- Returns
- None.
-
remove_bases
(ind)¶ Remove bases of self of index ind.
- Parameters
- indint or list or numpy.ndarray
The indices of the bases to remove.
- Returns
- tensap.SparseTensorProductFunctionalBasis
The SparseTensorProductFunctionalBasis with removed bases.
-
remove_mapping
(ind)¶
-
tensor_product_interpolation
(fun, *args)¶ Return the interpolation of function fun on a sparse grid.
- Parameters
- funfunction or tensap.Function
The function to interpolate.
- gridlist, optional
The grid of points used for the interpolation. If one grid has more points than the dimension of the corresponding basis, use magicPoints for the selection of a subset of points adapted to the basis. The default is None, indicating to use the method self.bases.interpolation_points().
- Returns
- tensap.FunctionalTensor
The interpolation of the function.
- outputdict
A dictionnary of outputs of the method.
- Raises
- ValueError
If the argument fun is neither a tensap.Function, a function nor a tensap.Tensor.
-
transpose
(perm)¶ Return self with the basis permutation perm.
- Parameters
- permlist or numpy.ndarray
The permutation of the bases.
- Returns
- tensap.SparseTensorProductFunctionalBasis
The SparseTensorProductFunctionalBasis with permuted bases.
tensap.approximation.bases.sub_functional_basis module¶
Module sub_functional_basis.
-
class
tensap.approximation.bases.sub_functional_basis.
SubFunctionalBasis
(underlying_basis=None, basis=None)¶ Bases:
tensap.approximation.bases.functional_basis.FunctionalBasis
Class SubFunctionalBasis.
- Attributes
- underlying_basistensap.FunctionalBasis
The underlying basis.
- basisnumpy.ndarray
Array of shape (n, m), where n is the number of elements in underlying_basis, which defines a set of m basis functions in the space generated by underlying_basis.
Methods
adaptation_path
()Return the adaptation path of the functional basis.
cardinal
()Return the number of basis functions.
conditional_expectation
()Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)).
derivative
(n)Compute the k-th order derivative of the functions of the basis projected on itself.
domain
()Return the domain of the set of basis functions, which is the support of the associated measure.
eval
(x[, indices])Return the evaluation of the basis functions at the points x.
eval_derivative
(n, x)Evaluate the k-th order derivative of the functions of the basis at the points x.
expectation
()Return the expectation of the basis functions.
interpolate
(y[, x])Provide an interpolation on a functional basis of a function (or values of the function) y associated with a set of n interpolation points x.
interpolation_points
(*args)Return the interpolation points for the basis.
kron
()Compute the Kronecker product of two bases.
magic_points
([x, J])Provide the magic points associated with a functional basis f selected in a given set of points x.
mean
()Return the mean of the basis functions.
ndim
()Return the dimension n for f defined in R^n.
Orthonormalize the SubFunctionalBasis.
plot
([indices, n])Plot the functions of the basis.
projection
(fun, G)Compute the projection of the function fun onto the functional basis using the integration rule G.
random
([n, measure])Evaluate the basis using n points drawn randomly according to measure if provided, or to self.measure otherwise.
storage
()Return the storage requirement of the FunctionalBasis.
christoffel
optimal_sampling_measure
-
cardinal
()¶ Return the number of basis functions.
- Returns
- int
The number of basis functions.
-
derivative
(n)¶ Compute the k-th order derivative of the functions of the basis projected on itself.
- Parameters
- kint
The order of the derivative.
- Returns
- tensap.SubFunctionalBasis
The k-th order derivative of the functions of the basis projected on itself.
-
domain
()¶ Return the domain of the set of basis functions, which is the support of the associated measure.
- Returns
- numpy.ndarray
The domain of the set of basis functions
-
eval
(x, indices=None)¶ Return the evaluation of the basis functions at the points x.
- Parameters
- xlist or numpy.ndarray
The points at which the basis functions are to be evaluted.
- Returns
- numpy.ndarray
The evaluations of the basis functions at the points x.
-
eval_derivative
(n, x)¶ Evaluate the k-th order derivative of the functions of the basis at the points x.
- Parameters
- kint
The order of the derivative.
- xlist or numpy.ndarray
The points at which the k-th derivative of the basis functions are to be evaluated.
- Returns
- numpy.ndarray
The evaluations of the k-th derivative of the functions of self.basis of degrees in self.indices at points x.
-
mean
()¶ Return the mean of the basis functions.
- Returns
- numpy.ndarray
The mean of the basis functions.
-
ndim
()¶ Return the dimension n for f defined in R^n.
- Returns
- int
The dimension n for f defined in R^n.
-
orthonormalize
()¶ Orthonormalize the SubFunctionalBasis.
- Returns
- tensap.SubFunctionalBasis
The orthonormalized SubFunctionalBasis.
-
storage
()¶ Return the storage requirement of the FunctionalBasis.
- Returns
- int
The storage requirement of the FunctionalBasis.
tensap.approximation.bases.user_defined_functional_basis module¶
Module user_defined_functional_basis.
-
class
tensap.approximation.bases.user_defined_functional_basis.
UserDefinedFunctionalBasis
(h_fun=None, measure=None, input_dim=None)¶ Bases:
tensap.approximation.bases.functional_basis.FunctionalBasis
Class UserDefinedFunctionalBasis.
The basis is not L2-orthonormal a priori, hence the is_orthonormal attribute remains at its default value of False.
- Attributes
- handle_funnumpy.ndarray
The functions making the basis.
- measuretensap.Measure
The measure associated with the basis. Can be a tensap.RandomVector or a tensap.RandomVariable to define a random generator and an expectation.
- input_dimensionint
The dimension of the domain of the functions in handle_fun.
Methods
adaptation_path
()Return the adaptation path of the functional basis.
cardinal
()Return the number of basis functions.
conditional_expectation
()Compute the conditional expectation of self with respect to the random variables dims (a subset of range(d)).
domain
()Return the domain of the set of basis functions, which is the support of the associated measure.
eval
(x)Return the evaluation of the basis functions at the points x.
expectation
()Return the expectation of the basis functions.
interpolate
(y[, x])Provide an interpolation on a functional basis of a function (or values of the function) y associated with a set of n interpolation points x.
interpolation_points
(*args)Return the interpolation points for the basis.
kron
()Compute the Kronecker product of two bases.
magic_points
([x, J])Provide the magic points associated with a functional basis f selected in a given set of points x.
mean
()Return the mean of the basis functions.
ndim
()Return the dimension n for f defined in R^n.
orthonormalize
()Orthonormalize the basis.
plot
([indices, n])Plot the functions of the basis.
projection
(fun, G)Compute the projection of the function fun onto the functional basis using the integration rule G.
random
([n, measure])Evaluate the basis using n points drawn randomly according to measure if provided, or to self.measure otherwise.
storage
()Return the storage requirement of the FunctionalBasis.
christoffel
optimal_sampling_measure
-
cardinal
()¶ Return the number of basis functions.
- Returns
- int
The number of basis functions.
-
domain
()¶ Return the domain of the set of basis functions, which is the support of the associated measure.
- Returns
- numpy.ndarray
The domain of the set of basis functions
-
eval
(x)¶ Return the evaluation of the basis functions at the points x.
- Parameters
- xlist or numpy.ndarray
The points at which the basis functions are to be evaluted.
- Returns
- numpy.ndarray
The evaluations of the basis functions at the points x.
-
ndim
()¶ Return the dimension n for f defined in R^n.
- Returns
- int
The dimension n for f defined in R^n.