aub_htp.random.spectral_measure_sampler#

Functions

isotropic_scale_correction(dimentions, ...)

Classes

BaseSpectralMeasureSampler()

Spectral Measure Sampler is an interface to define the sampling algorithm for a spectral measure.

DiscreteSampler(alpha, positions, weights)

EllipticSampler(number_of_dimensions, alpha, ...)

IsotropicSampler(number_of_dimensions, ...)

MixedSampler(spectral_measures, weights)

UnivariateSampler(alpha, beta, gamma)

class aub_htp.random.spectral_measure_sampler.BaseSpectralMeasureSampler#

Bases: ABC

Spectral Measure Sampler is an interface to define the sampling algorithm for a spectral measure. The underlying mathematical spectral measure \(\Lambda\) has to uphold the following property:

\[\int_{\mathbb{S}^{d-1}}s\Lambda(ds)=0\]

To create a custom spectral measure sampler, you need to inherit from this class and implement the following methods:

Example:

class CustomSpectralMeasureSampler(BaseSpectralMeasureSampler):
    def sample(self, number_of_samples: int, random_state: None | int | np.random.RandomState | np.random.Generator = None) -> np.ndarray:
        random_state = get_random_state_generator(random_state)
        return random_state.rand(number_of_samples, self.dimensions())
    def dimensions(self) -> int:
        return 2
    def mass(self) -> float:
        return 1.0
abstractmethod dimensions() int#

Number of dimensions of the vector space of the spectral measure.

Returns#

dimensions : int

abstractmethod mass() float#

Mass of the spectral measure.

Returns#

mass : float

abstractmethod sample(number_of_samples: int, random_state: None | int | RandomState | Generator = None) ndarray#

Sampling algorithm for the spectral measure sampler.

Parameters#

number_of_samplesint

The number of samples to draw from the spectral measure.

random_stateNone | int | np.random.RandomState | np.random.Generator, optional

The random state to use for the sampling. You are encouraged to use aub_htp.random.get_random_state_generator() to get a random state generator as such: random_state = get_random_state_generator(random_state)

Returns#

samplesnp.ndarray

The samples from the spectral measure.

class aub_htp.random.spectral_measure_sampler.DiscreteSampler(alpha: float, positions: ndarray, weights: ndarray)#

Bases: BaseSpectralMeasureSampler

dimensions() int#

Number of dimensions of the vector space of the spectral measure.

Returns#

dimensions : int

mass() float#

Mass of the spectral measure.

Returns#

mass : float

sample(number_of_samples: int, random_state: None | int | RandomState | Generator = None) ndarray#

Sampling algorithm for the spectral measure sampler.

Parameters#

number_of_samplesint

The number of samples to draw from the spectral measure.

random_stateNone | int | np.random.RandomState | np.random.Generator, optional

The random state to use for the sampling. You are encouraged to use aub_htp.random.get_random_state_generator() to get a random state generator as such: random_state = get_random_state_generator(random_state)

Returns#

samplesnp.ndarray

The samples from the spectral measure.

class aub_htp.random.spectral_measure_sampler.EllipticSampler(number_of_dimensions: int, alpha: float, sigma: ndarray, mass: float | None = None)#

Bases: BaseSpectralMeasureSampler

dimensions() int#

Number of dimensions of the vector space of the spectral measure.

Returns#

dimensions : int

mass() float#

Mass of the spectral measure.

Returns#

mass : float

sample(number_of_samples: int, random_state: None | int | RandomState | Generator = None) ndarray#

Sampling algorithm for the spectral measure sampler.

Parameters#

number_of_samplesint

The number of samples to draw from the spectral measure.

random_stateNone | int | np.random.RandomState | np.random.Generator, optional

The random state to use for the sampling. You are encouraged to use aub_htp.random.get_random_state_generator() to get a random state generator as such: random_state = get_random_state_generator(random_state)

Returns#

samplesnp.ndarray

The samples from the spectral measure.

class aub_htp.random.spectral_measure_sampler.IsotropicSampler(number_of_dimensions: int, alpha: float, gamma: float)#

Bases: BaseSpectralMeasureSampler

dimensions() int#

Number of dimensions of the vector space of the spectral measure.

Returns#

dimensions : int

mass() float#

Mass of the spectral measure.

Returns#

mass : float

sample(number_of_samples: int, random_state: None | int | RandomState | Generator = None) ndarray#

Sampling algorithm for the spectral measure sampler.

Parameters#

number_of_samplesint

The number of samples to draw from the spectral measure.

random_stateNone | int | np.random.RandomState | np.random.Generator, optional

The random state to use for the sampling. You are encouraged to use aub_htp.random.get_random_state_generator() to get a random state generator as such: random_state = get_random_state_generator(random_state)

Returns#

samplesnp.ndarray

The samples from the spectral measure.

class aub_htp.random.spectral_measure_sampler.MixedSampler(spectral_measures: list[BaseSpectralMeasureSampler], weights: ndarray)#

Bases: BaseSpectralMeasureSampler

dimensions() int#

Number of dimensions of the vector space of the spectral measure.

Returns#

dimensions : int

mass() float#

Mass of the spectral measure.

Returns#

mass : float

sample(number_of_samples: int, random_state: None | int | RandomState | Generator = None) ndarray#

Sampling algorithm for the spectral measure sampler.

Parameters#

number_of_samplesint

The number of samples to draw from the spectral measure.

random_stateNone | int | np.random.RandomState | np.random.Generator, optional

The random state to use for the sampling. You are encouraged to use aub_htp.random.get_random_state_generator() to get a random state generator as such: random_state = get_random_state_generator(random_state)

Returns#

samplesnp.ndarray

The samples from the spectral measure.

class aub_htp.random.spectral_measure_sampler.UnivariateSampler(alpha: float, beta: float, gamma: float)#

Bases: BaseSpectralMeasureSampler

dimensions() int#

Number of dimensions of the vector space of the spectral measure.

Returns#

dimensions : int

mass() float#

Mass of the spectral measure.

Returns#

mass : float

sample(number_of_samples: int, random_state: None | int | RandomState | Generator = None) ndarray#

Sampling algorithm for the spectral measure sampler.

Parameters#

number_of_samplesint

The number of samples to draw from the spectral measure.

random_stateNone | int | np.random.RandomState | np.random.Generator, optional

The random state to use for the sampling. You are encouraged to use aub_htp.random.get_random_state_generator() to get a random state generator as such: random_state = get_random_state_generator(random_state)

Returns#

samplesnp.ndarray

The samples from the spectral measure.

aub_htp.random.spectral_measure_sampler.isotropic_scale_correction(dimentions: int, alpha: float, gamma_scale: float)#