uadapy package

Subpackages

Module contents

class uadapy.CorrelatedDistributions(distributions: list[Distribution], covariance_matrix=None)

Bases: object

Class for managing and analyzing correlated distributions or time series.

distributions

List of individual distributions or timeseries.

Type:

list[Distribution] or list[Timeseries]

n_distributions

Number of distributions or timeseries.

Type:

int

covariance_matrix

Pairwise covariance matrix of the distributions.

Type:

np.ndarray

cov(dim_i: int, dim_j: int) ndarray | float

Returns the covariance matrix between two distributions.

Parameters:
  • dim_i (int) – Index of the first distribution.

  • dim_j (int) – Index of the second distribution.

Returns:

Covariance matrix between i-th and j-th distribution.

Return type:

np.ndarray

mean(dim_i: int) float

Returns the mean of the i-th distribution.

Parameters:

dim_i (int) – Index of the distribution.

Returns:

Mean of the i-th distribution.

Return type:

float

sample(n_samples: int, seed: int | None = None) ndarray

Samples from the joint distribution of all correlated distributions in block structure.

Parameters:
  • n_samples (int) – Number of samples to draw.

  • seed (int, optional) – Seed for random number generation.

Returns:

Samples from the joint distribution.

Return type:

np.ndarray

class uadapy.Distribution(model, name='', n_dims=1)

Bases: object

The Distribution class provides a consistent interface to a variety of distributions.

model

The underlying concrete distribution model, a scipy.stats distribution object or an array of samples

name

Name of the distribution type, e.g. ‘Normal’

Type:

str

n_dims

Dimensionality of the distribution

Type:

int

cov() ndarray | float

Covariance of the distribution.

Returns:

Covariance of the distribution.

Return type:

np.ndarray or float

kurt() ndarray | float

Kurtosis of the distribution.

Returns:

Kurtosis of the distribution.

Return type:

np.ndarray or float

mean() ndarray | float

Expected value of the distribution.

Returns:

Expected value of the distribution.

Return type:

np.ndarray or float

pdf(x: ndarray | float) ndarray | float

Computes the probability density function.

Parameters:

x (np.ndarray or float) – The position where the pdf should be evaluated.

Returns:

Probability values of the distribution at the given sample points.

Return type:

np.ndarray or float

sample(n: int, seed: int | None = None) ndarray

Creates samples from the distribution.

Parameters:
  • n (int) – Number of samples.

  • seed (int, optional) – Seed for the random number generator for reproducibility, default is None.

Returns:

Samples of the distribution.

Return type:

np.ndarray

skew() ndarray | float

Skewness of the distribution.

Returns:

Skewness of the distribution.

Return type:

np.ndarray or float

class uadapy.TimeSeries(model, timesteps, name='', n_dims=1)

Bases: object

The TimeSeries class provides a consistent interface to model an uncertain, univariate time series. It strongly builds on the Distribution class. It provides wrapper functions to some of the important functions of the Distribution class and adds additional convenience functions that are commonly used in time series.

distribution

The underlying distribution of the time series

Type:

Distribution

timesteps

The time steps of the time series

Type:

int

cov() ndarray | float

Covariance of the time series.

Returns:

Covariance of all time series points.

Return type:

np.ndarray or float

mean() ndarray | float

Expected value of the time series.

Returns:

Expected value of the time series.

Return type:

np.ndarray or float

pdf(x: ndarray | float) ndarray | float

Computes the probability density function based on the whole probability distribution of the time series.

Parameters:

x (np.ndarray or float) – The position where the pdf should be evaluated.

Returns:

Probability values of the distribution at the given sample points.

Return type:

np.ndarray or float

sample(n: int, seed: int | None = None) ndarray

Creates samples from the time series (one specific instance).

Parameters:
  • n (int) – Number of samples (time series).

  • seed (int, optional) – Seed for the random number generator for reproducibility, default is None.

Returns:

Time series instances that represent samples of the distribution.

Return type:

np.ndarray

variance() ndarray | float

Variance of the time series.

Returns:

Variance of the time series.

Return type:

np.ndarray or float