Sampling¶
sampling
¶
Sampling routines for optimal weighted least squares.
This module provides routines for sampling from the optimal sampling distribution. Given a polynomial space \(V:= \text{span} \{P_\lambda: \lambda \in \Lambda\}\) defined by a multi-index set \(\Lambda \subset \mathbb{N}_0^d\), there exists an optimal sampling distribution \(\nu = \nu(V)\) that minimizes the number of samples required for the weighted least squares estimator onto \(V\). This module also contains routines for arcsine sampling and determining the optimal sample size for quasi-optimality of the weighted least squares estimator.
Functions:
Name | Description |
---|---|
arcsine |
Arcsine density function. |
sample_arcsine |
Samples from the arcsine distribution. |
sample_squared_legendre |
Samples from the distribution with squared Legendre density. |
optimal_sample_size |
Optimal sample size for quasi-optimality. |
sample_optimal_distribution |
Samples from the optimal distribution. |
multichaos.sampling.arcsine
¶
Arcsine density function.
This evaluates the arcsine density function
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
np.ndarray
|
Input array. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
Arcsine density function evaluated at |
multichaos.sampling.sample_arcsine
¶
Samples from the arcsine distribution.
This is based on the fact that if \(U \sim \mathcal{U}(-\pi, \pi)\), then \(X = \sin(U) \sim p_1\) follows the arcsine distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size
|
tuple
|
Size of the sample. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
Sample from the arcsine distribution with shape |
multichaos.sampling.sample_squared_legendre
¶
Samples from the distribution with squared Legendre density.
This function samples from the distribution with squared Legendre density \(P_n^2\), where \(P_n\) is the Legendre polynomial of degree \(n\). This is done using rejection sampling with arcsine proposals, since
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n
|
int
|
Degree of Legendre polynomial. |
required |
size
|
int
|
Number of samples. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
Sample from the square Legendre density with shape |
multichaos.sampling.optimal_sample_size
¶
Optimal sample size for quasi-optimality.
Determines the optimal number of samples \(N\) required to ensure quasi-optimality of a weighted least squares estimator onto a polynomial space \(V\). For \(p \in (0, 1)\) and \(\theta = \frac{1}{2}(1 - \log 2)\), the condition
where \(m = \text{dim}(V)\), ensures that
where \(\mathbf{G} \in \mathbb{R}^{m \times m}\) denotes the Gramian least squares and \(\mathbf{I} \in \mathbb{R}^{m \times m}\) the identity matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
float
|
Dimension of the polynomial space used for projection. |
required |
risk
|
float
|
Probability \(p\) for quasi-optimality to hold. |
0
|
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Optimal sample size. |
multichaos.sampling.sample_optimal_distribution
¶
Samples from the optimal distribution.
Given a polynomial subspace \(\text{span} \{P_\lambda: \lambda \in \Lambda\} \subset L^2([-1, 1]^d)\) defined by an index set \(\Lambda \subset \mathbb{N}_0^d\), the density of the optimal distribution is defined by
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index_set
|
np.ndarray
|
Index set defining the polynomial subspace of shape |
required |
size
|
int
|
Number of samples. |
required |
Returns:
Type | Description |
---|---|
np.ndarray
|
Samples with shape |