Simplex

The Simplex class generates uniformly distributed samples inside a simplex of dimension \(n_d\), whose coordinates are expressed by \(\zeta_k\). First, this class generates \(n_d\) independent uniform random variables on [0, 1], denoted \(r_q\), then maps them to the simplex as follows:

\[\mathbf{M_{n_d}} = \zeta_0 + \sum_{i=1}^{n_d} \Big{[}\prod_{j=1}^{i} r_{n_d-j+1}^{\frac{1}{n_d-j+1}}\Big{]}(\zeta_i - \zeta_{i-1})\]

where \(M_{n_d}\) is an \(n_d\) dimensional array defining the coordinates of new sample. This mapping is illustrated below for a two-dimensional simplex.

Randomly generated point inside a 2-D simplex

Additional details can be found in [21].

Simplex Class

The SimplexSampling class is imported using the following command:

>>> from UQpy.sampling.SimplexSampling import SimplexSampling

Methods

class SimplexSampling(nodes=None, nsamples=None, random_state=None)[source]

Generate uniform random samples inside an n-dimensional simplex.

Parameters:
  • nodes (Union[list, ndarray, None]) – The vertices of the simplex.

  • nsamples (Optional[int]) – The number of samples to be generated inside the simplex. If nsamples is provided when the object is defined, the run() method will be called automatically. If nsamples is not provided when the object is defined, the user must invoke the run() method and specify nsamples.

  • random_state (Union[None, int, RandomState, Generator]) – Random seed used to initialize the pseudo-random number generator. Default is None. If an int is provided, this sets the seed for an object of numpy.random.RandomState. Otherwise, the object itself can be passed directly.

run(nsamples)[source]

Execute the random sampling in the SimplexSampling class. The run() method is the function that performs random sampling in the SimplexSampling class. If nsamples is provided called when the SimplexSampling object is defined, the run() method is automatically. The user may also call the run() method directly to generate samples. The run() method of the SimplexSampling class can be invoked many times and each time the generated samples are appended to the existing samples.

Parameters:

nsamples (int) – Number of samples to be generated inside the simplex. If the run() method is invoked multiple times, the newly generated samples will be appended to the existing samples.

Returns:

The run() method has no returns, although it creates and/or appends the samples attribute of the SimplexSampling class.

Attributes

SimplexSampling.samples: ndarray

Examples