Symmetric Generalized Normal Distribution#
- class SymmetricGeneralizedNormalDistribution(amplitude: float = 1.0, shape: float = 1.0, loc: float = 0.0, scale: float = 1.0, normalize: bool = False)[source]#
Bases:
BaseDistributionClass for SymmetricGeneralizedNormalDistribution.
- Parameters:
amplitude (float, optional) – The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is
True.shape (float, optional) – The shape parameter, \(\beta\). Defaults to 1.0.
loc (float, optional) – The shape parameter, \(\mu\). Defaults to 0.0.
scale (float, optional) – The standard deviation parameter, \(\alpha\). Defaults to 1.0.
normalize (bool, optional) – If
True, the distribution is normalized so that the total area under the PDF equals 1. Defaults toFalse.
- Raises:
NegativeAmplitudeError – If the provided value of amplitude is negative.
NegativeScaleError – If the provided value of scale parameter is negative.
- Attributes:
Methods
cdf(x)Compute the cumulative density function (CDF) for the distribution.
from_scipy_params(beta[, loc, scale])Instantiate SymmetricGeneralizedNormalDistribution with scipy parametrization.
logcdf(x)Compute the log cumulative density function (logCDF) for the distribution.
logpdf(x)Compute the log probability density function (logPDF) for the distribution.
pdf(x)Compute the probability density function (PDF) for the distribution.
scipy_like(beta[, loc, scale])Instantiate SymmetricGeneralizedNormalDistribution with scipy parametrization.
stats()Computes and returns the statistical properties of the distribution, including,
Examples
Importing libraries:
3import matplotlib.pyplot as plt 4import numpy as np 5from scipy.stats import norm 6 7from pymultifit.distributions import GaussianDistribution
- Generating a standard SymmetricGeneralizedNormalDistribution(\(\beta=1, \mu=0, \alpha = 1\))
with
pyMultiFitandscipy:
9x_values = np.linspace(start=-10, stop=10, num=500) 10 11y_multifit = SymmetricGeneralizedNormalDistribution(normalize=True) 12y_scipy = gennorm
Plotting PDF and CDF:
14f, ax = plt.subplots(1, 2, figsize=(12, 5)) 15 16ax[0].plot(x_values, y_scipy.pdf(x=x_values, beta=1), label='Scipy GenNorm') 17ax[0].plot(x_values, y_multifit.pdf(x_values), 'k:', label='pyMultiFit GenNorm') 18ax[0].set_ylabel('f(x)') 19 20ax[1].plot(x_values, y_scipy.cdf(x=x_values, beta=1), label='Scipy GenNorm') 21ax[1].plot(x_values, y_multifit.cdf(x_values), 'k:', label='pyMultiFit GenNorm') 22ax[1].set_ylabel('F(x)') 23 24f.suptitle('GenNorm(1, 0, 1)') 25 26for i in ax: 27 i.set_xlabel('X') 28 i.legend() 29plt.tight_layout()
Generating a scaled and translated SymmetricGeneralizedNormalDistribution(\(\beta=2, \mu=-3, \alpha=5\)):
32y_multifit = SymmetricGeneralizedNormalDistribution(shape=2, loc=-3, scale=5, normalize=True)
Plotting PDF and CDF:
34f, ax = plt.subplots(1, 2, figsize=(12, 5)) 35 36ax[0].plot(x_values, y_scipy.pdf(x=x_values, beta=2, loc=-3, scale=5), label='Scipy translated GenNorm') 37ax[0].plot(x_values, y_multifit.pdf(x_values), 'k:', label='pyMultiFit translated GenNorm') 38ax[0].set_ylabel('f(x)') 39 40ax[1].plot(x_values, y_scipy.cdf(x=x_values, beta=2, loc=-3, scale=5), label='Scipy translated GenNorm') 41ax[1].plot(x_values, y_multifit.cdf(x_values), 'k:', label='pyMultiFit translated GenNorm') 42ax[1].set_ylabel('F(x)') 43 44f.suptitle(r'GenNorm(2, -3, 5)') 45 46for i in ax: 47 i.set_xlabel('X') 48 i.legend() 49plt.tight_layout()
- cdf(x: ndarray) ndarray[source]#
Compute the cumulative density function (CDF) for the distribution.
- Parameters:
x – Input array at which to evaluate the CDF.
- classmethod from_scipy_params(beta, loc: float = 0.0, scale: float = 1.0)[source]#
Instantiate SymmetricGeneralizedNormalDistribution with scipy parametrization.
- Parameters:
- beta: float
The shape parameter.
- loc: float, optional
The mean parameter. Defaults to 0.0.
- scale: float, optional
The scale parameter. Defaults to 1.0.
- Returns:
- SymmetricGeneralizedNormalDistribution
An instance of normalized SymmetricGeneralizedNormalDistribution.
- logcdf(x: ndarray) ndarray#
Compute the log cumulative density function (logCDF) for the distribution.
- Parameters:
x – Input array at which to evaluate the logCDF.
- logpdf(x: ndarray) ndarray#
Compute the log probability density function (logPDF) for the distribution.
- Parameters:
x – Input array at which to evaluate the logPDF.
- pdf(x: ndarray) ndarray[source]#
Compute the probability density function (PDF) for the distribution.
- Parameters:
x – Input array at which to evaluate the PDF.
- classmethod scipy_like(beta, loc: float = 0.0, scale: float = 1.0)[source]#
Instantiate SymmetricGeneralizedNormalDistribution with scipy parametrization.
- Parameters:
- beta: float
The shape parameter.
- loc: float, optional
The mean parameter. Defaults to 0.0.
- scale: float, optional
The scale parameter. Defaults to 1.0.
- Returns:
- SymmetricGeneralizedNormalDistribution
An instance of normalized SymmetricGeneralizedNormalDistribution.
Deprecated since version 1.0.7: Use from_scipy_params instead of scipy_like. scipy_like will be removed in a future release.
- stats() Dict[str, float][source]#
Computes and returns the statistical properties of the distribution, including,
mean,
median,
variance, and
standard deviation.
- Returns:
A dictionary containing statistical properties such as mean, variance, etc.
- Return type:
Notes
If any of the parameter is not computable for a distribution, this method returns None.
This class internally utilizes the following functions from utilities_d module:
Recommended Import#
from pymultifit.distributions import SymmetricGeneralizedNormalDistribution
Full Import#
from pymultifit.distributions.generalized.genNorm_d import SymmetricGeneralizedNormalDistribution