SkewNormal Distribution#

class SkewNormalDistribution(amplitude: float = 1.0, shape: float = 1.0, location: float = 0.0, scale: float = 1.0, normalize: bool = False)[source]#

Bases: BaseDistribution

Class for SkewNormal distribution.

Parameters:
  • amplitude (float, optional) – The amplitude of the PDF. Defaults to 1.0. Ignored if normalize is True.

  • shape (float, optional) – The mean parameter, \(\mu\). Defaults to 0.0.

  • scale (float, optional) – The scale parameter, for scaling. Defaults to 1.0,

  • location (float, optional) – The location parameter, for shifting. Defaults to 0.0.

  • normalize (bool, optional) – If True, the distribution is normalized so that the total area under the PDF equals 1. Defaults to False.

Raises:
Attributes:
mean

The mean of the distribution.

median

The median of the distribution.

mode

The mode of the distribution.

stddev

The standard deviation of the distribution.

variance

The variance of the distribution.

Methods

cdf(x)

Compute the cumulative density function (CDF) for the distribution.

from_scipy_params(a[, loc, scale])

Instantiate SkewNormalDistribution 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(a[, loc, scale])

Instantiate SkewNormalDistribution 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 skewnorm
6
7from pymultifit.distributions import SkewNormalDistribution

Generating a standard Skew Normal(\(\xi=1, \mu = 0, \sigma = 1\)) distribution with pyMultiFit and scipy:

 9x_values = np.linspace(start=-10, stop=10, num=500)
10
11y_multifit = SkewNormalDistribution(normalize=True)
12y_scipy = skewnorm

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, a=1), label='Scipy Skew Normal')
17ax[0].plot(x_values, y_multifit.pdf(x_values), 'k:', label='pyMultiFit Skew Normal')
18ax[0].set_ylabel('f(x)')
19
20ax[1].plot(x_values, y_scipy.cdf(x=x_values, a=1), label='Scipy Skew Normal')
21ax[1].plot(x_values, y_multifit.cdf(x_values), 'k:', label='pyMultiFit Skew Normal')
22ax[1].set_ylabel('F(x)')
23
24f.suptitle('Skew Normal(1, 0, 1)')
25
26for i in ax:
27    i.set_xlabel('X')
28    i.legend()
29plt.tight_layout()
SkewNormal(1, 0, 1)

Generating a translated Skew Normal(\(\xi=3, \mu=-3, \sigma=3\)) distribution:

32y_multifit = SkewNormalDistribution(shape=3, scale=3, location=-3, 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, a=3, loc=-3, scale=3), label='Scipy translated Skew Normal')
37ax[0].plot(x_values, y_multifit.pdf(x_values), 'k:', label='pyMultiFit translated Skew Normal')
38ax[0].set_ylabel('f(x)')
39
40ax[1].plot(x_values, y_scipy.cdf(x=x_values, a=3, loc=-3, scale=3), label='Scipy translated Skew Normal')
41ax[1].plot(x_values, y_multifit.cdf(x_values), 'k:', label='pyMultiFit translated Skew Normal')
42ax[1].set_ylabel('F(x)')
43
44f.suptitle(r'Skew Normal(3, -3, 3)')
45
46for i in ax:
47    i.set_xlabel('X')
48    i.legend()
49plt.tight_layout()
Skew Normal(3, -3, 3)
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(a: float, loc: float = 0.0, scale: float = 1.0)[source]#

Instantiate SkewNormalDistribution with scipy parametrization.

Parameters:
afloat

The skewness parameter.

locfloat, optional

The location parameter. Defaults to 0.0.

scalefloat, optional

The scale parameter. Defaults to 1.0.

Returns:
SkewNormalDistribution

An instance of normalized SkewNormalDistribution.

logcdf(x: ndarray) ndarray[source]#

Compute the log cumulative density function (logCDF) for the distribution.

Parameters:

x – Input array at which to evaluate the logCDF.

logpdf(x: ndarray) ndarray[source]#

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(a: float, loc: float = 0.0, scale: float = 1.0)[source]#

Instantiate SkewNormalDistribution with scipy parametrization.

Parameters:
afloat

The skewness parameter.

locfloat, optional

The location parameter. Defaults to 0.0.

scalefloat, optional

The scale parameter. Defaults to 1.0.

Returns:
SkewNormalDistribution

An instance of normalized SkewNormalDistribution.

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,

  1. mean,

  2. median,

  3. variance, and

  4. standard deviation.

Returns:

A dictionary containing statistical properties such as mean, variance, etc.

Return type:

Dict[str, float]

Notes

If any of the parameter is not computable for a distribution, this method returns None.

property mean: float | None#

The mean of the distribution.

property median: float | None#

The median of the distribution.

property mode: float | None#

The mode of the distribution.

property stddev: float | None#

The standard deviation of the distribution.

property variance: float | None#

The variance of the distribution.

This class internally utilizes the following functions from utilities_d module:

Full Import#

from pymultifit.distributions.skewNormal_d import SkewNormalDistribution