macro_eeg_model.simulation.distributions#

Classes#

LagDistributions

An enumeration for different types of lag distributions.

DistributionFactory

A factory class responsible for creating different types of distributions based on the provided type.

InverseGEV

A class representing the inverse generalized extreme value (GEV) distribution.

InverseGEVSum

A class representing the sum of two inverse GEV distributions.

Module Contents#

class macro_eeg_model.simulation.distributions.LagDistributions(*args, **kwds)[source]#

Bases: enum.Enum

An enumeration for different types of lag distributions.

INVERSE_GEV#

Represents an inverse generalized extreme value (GEV) distribution.

Type:

str

INVERSE_GEV_SUM#

Represents the sum of two inverse GEV distributions.

Type:

str

__init__(*args, **kwds)#
class macro_eeg_model.simulation.distributions.DistributionFactory[source]#

A factory class responsible for creating different types of distributions based on the provided type.

static get_distribution(distribution_type, **kwargs)[source]#

Creates and returns a distribution object based on the specified type.

Parameters:
  • distribution_type (LagDistributions) – The type of distribution to create (e.g., INVERSE_GEV, INVERSE_GEV_SUM).

  • kwargs (dict) – The parameters required to initialize the distribution.

Returns:

An instance of a distribution class (e.g., InverseGEV, InverseGEVSum).

Return type:

rv_continuous

Raises:

ValueError – If an unknown distribution type is provided.

class macro_eeg_model.simulation.distributions.InverseGEV(lmbd, mu, sigma, xi, *args, **kwargs)[source]#

Bases: scipy.stats.rv_continuous

A class representing the inverse generalized extreme value (GEV) distribution.

This class extends scipy.stats.rv_continuous to model the inverse GEV distribution.

lmbd#

A scaling parameter applied to the distribution.

Type:

float

mu#

The location parameter of the GEV distribution.

Type:

float

sigma#

The scale parameter of the GEV distribution.

Type:

float

xi#

The shape parameter of the GEV distribution.

Type:

float

__init__(lmbd, mu, sigma, xi, *args, **kwargs)[source]#

Initializes the InverseGEV distribution with the specified parameters.

Parameters:
  • lmbd (float) – A scaling parameter applied to the distribution.

  • mu (float) – The location parameter of the GEV distribution.

  • sigma (float) – The scale parameter of the GEV distribution.

  • xi (float) – The shape parameter of the GEV distribution.

_argcheck(*args)[source]#

Validates the distribution parameters.

Returns:

True if the parameters are valid, False otherwise.

Return type:

bool

_cdf(x, *args)[source]#

Calculates the cumulative distribution function (CDF) for the inverse GEV.

Parameters:

x (array_like) – The quantiles at which to evaluate the CDF.

Returns:

The CDF evaluated at the given quantiles.

Return type:

array_like

_pdf(x, *args)[source]#

Calculates the probability density function (PDF) for the inverse GEV.

Parameters:

x (array_like) – The quantiles at which to evaluate the PDF.

Returns:

The PDF evaluated at the given quantiles.

Return type:

array_like

_ppf(q, *args)[source]#

Calculates the percent point function (PPF), also known as the quantile function, for the inverse GEV.

Parameters:

q (array_like) – The quantiles for which to evaluate the PPF.

Returns:

The PPF evaluated at the given quantiles.

Return type:

array_like

_rvs(*args, size=None, random_state=None)[source]#

Generates random variates from the inverse GEV distribution.

Parameters:
  • size (int or tuple of ints, optional) – The number of random variates to generate.

  • random_state (np.random.RandomState, optional) – A random state instance for reproducibility.

Returns:

The generated random variates.

Return type:

array_like

class macro_eeg_model.simulation.distributions.InverseGEVSum(lmbd1, lmbd2, mu, sigma, xi, *args, **kwargs)[source]#

Bases: scipy.stats.rv_continuous

A class representing the sum of two inverse GEV distributions.

This class extends scipy.stats.rv_continuous to model the sum of two inverse GEV distributions. The sum is approximated using a kernel density estimate (KDE) of the sum of samples from the two distributions.

lmbd1#

A scaling parameter for the first inverse GEV distribution.

Type:

float

lmbd2#

A scaling parameter for the second inverse GEV distribution.

Type:

float

mu#

The location parameter of the GEV distributions.

Type:

float

sigma#

The scale parameter of the GEV distributions.

Type:

float

xi#

The shape parameter of the GEV distributions.

Type:

float

_kde#

The kernel density estimate of the sum of the two inverse GEV distributions.

Type:

KernelDensity

__init__(lmbd1, lmbd2, mu, sigma, xi, *args, **kwargs)[source]#

Initializes the InverseGEVSum distribution with the specified parameters.

Parameters:
  • lmbd1 (float) – A scaling parameter for the first inverse GEV distribution.

  • lmbd2 (float) – A scaling parameter for the second inverse GEV distribution.

  • mu (float) – The location parameter of the GEV distributions.

  • sigma (float) – The scale parameter of the GEV distributions.

  • xi (float) – The shape parameter of the GEV distributions.

_get_kde()[source]#

Generates a kernel density estimate (KDE) for the sum of two inverse GEV distributions.

Returns:

A KDE fitted to the sum of samples from the two inverse GEV distributions.

Return type:

KernelDensity

_argcheck(*args)[source]#

Validates the distribution parameters.

Returns:

True if the parameters are valid, False otherwise.

Return type:

bool

_pdf(x, *args)[source]#

Evaluates the kernel density estimate (KDE) at the given quantiles to approximate the probability density function (PDF) for the sum of inverse GEVs.

Parameters:

x (array_like) – The quantiles at which to evaluate the PDF.

Returns:

The PDF evaluated at the given quantiles.

Return type:

array_like