Skewt-Scipy
is a Python package for skew student
We employ the definition of the skew-t distribution from Azzalini (2014, Section 4.3.1). Firstly, we need two density functions:
where
where
The skew-t variable can be defined as:
where
where
Install via pip with
python3 -m pip install skewt_scipy
As the class skewt
inherits from the class rv_continuous
of Scipy
, many methods are available. The shape parameters a
and df
represent
Method | Description |
---|---|
rvs(a, df, loc=0, scale=1, size=1, random_state=None) |
Random variates. |
pdf(x, a, df, loc=0, scale=1) |
Probability density function. |
logpdf(x, a, df, loc=0, scale=1) |
Log of the probability density function. |
cdf(x, a, df, loc=0, scale=1) |
Cumulative distribution function. |
logcdf(x, a, df, loc=0, scale=1) |
Log of the cumulative distribution function. |
ppf(q, a, df, loc=0, scale=1) |
Percent point function (inverse of cdf ). |
stats(a, df, loc=0, scale=1, moments='mvsk') |
Mean('m'), variance('v'), skew('s'), and/or kurtosis('k'). |
fit(data) |
Parameter estimates for generic data. |
Note that the parameters
import numpy as np
from skewt_scipy.skewt import skewt
# random number generator
skewt.rvs(a=10, df=6, loc=3, scale=2, size=10)
# probability distribution
x = (np.linspace(-50, 50, 100),)
skewt.pdf(x=x, a=-10, df=6, loc=3, scale=2)
# log of probability distribution
skewt.logpdf(x=x, a=-10, df=6, loc=3, scale=2)
# cumulative distribution
skewt.cdf(x=x, a=8, df=10, loc=3, scale=2)
# log of cumulative distribution
skewt.logcdf(x=x, a=8, df=10, loc=3, scale=2)
# percent point function
skewt.ppf(np.array([0.5, 0.9, 0.99]), a=3, df=6, loc=3, scale=2)
a = 3
df = 5
loc = 3
scale = 2
data = skewt.rvs(a=a, scale=scale, df=df, loc=loc, size=10000, random_state=123)
skewt.fit(data)
skewt.fit(data, fdf=df) # fixed df
skewt.fit(data, fa=a, fdf=df) # fixed a and df