3.3.2.2.1. statsmodels.distributions.edgeworth.ExpandedNormal¶
-
class
statsmodels.distributions.edgeworth.ExpandedNormal(cum, name='Edgeworth expanded normal', **kwds)[source]¶ Construct the Edgeworth expansion pdf given cumulants.
Parameters: cum: array_like
cum[j] contains (j+1)-th cumulant: cum[0] is the mean, cum[1] is the variance and so on.
Notes
This is actually an asymptotic rather than convergent series, hence higher orders of the expansion may or may not improve the result. In a strongly non-Gaussian case, it is possible that the density becomes negative, especially far out in the tails.
References
[R19] E.A. Cornish and R.A. Fisher, Moments and cumulants in the specification of distributions, Revue de l’Institut Internat. de Statistique. 5: 307 (1938), reprinted in R.A. Fisher, Contributions to Mathematical Statistics. Wiley, 1950. [R20] http://en.wikipedia.org/wiki/Edgeworth_series [R21] S. Blinnikov and R. Moessner, Expansions for nearly Gaussian distributions, Astron. Astrophys. Suppl. Ser. 130, 193 (1998) Examples
Construct the 4th order expansion for the chi-square distribution using the known values of the cumulants:
>>> from scipy.misc import factorial >>> df = 12 >>> chi2_c = [2**(j-1) * factorial(j-1) * df for j in range(1, 5)] >>> edgw_chi2 = ExpandedNormal(chi2_c, name='edgw_chi2', momtype=0)
Calculate several moments: >>> m, v = edgw_chi2.stats(moments=’mv’) >>> np.allclose([m, v], [df, 2 * df]) True
Plot the density function: >>> mu, sigma = df, np.sqrt(2*df) >>> x = np.linspace(mu - 3*sigma, mu + 3*sigma) >>> plt.plot(x, stats.chi2.pdf(x, df=df), ‘g-‘, lw=4, alpha=0.5) >>> plt.plot(x, stats.norm.pdf(x, mu, sigma), ‘b–’, lw=4, alpha=0.5) >>> plt.plot(x, edgw_chi2.pdf(x), ‘r-‘, lw=2) >>> plt.show()
3.3.2.2.1.1. Methods¶
__init__(cum[, name]) |
|
cdf(x, *args, **kwds) |
Cumulative distribution function of the given RV. |
entropy(*args, **kwds) |
Differential entropy of the RV. |
est_loc_scale(*args, **kwds) |
est_loc_scale is deprecated! |
expect([fn, args, loc, scale, lb, ub, ...]) |
calculate expected value of a function with respect to the distribution |
fit(data, *args, **kwds) |
Return MLEs for shape, location, and scale parameters from data. |
fit_fr(data, *args, **kwds) |
estimate distribution parameters by MLE taking some parameters as fixed |
fit_loc_scale(data, *args) |
Estimate loc and scale parameters from data using 1st and 2nd moments. |
freeze(*args, **kwds) |
Freeze the distribution for the given arguments. |
interval(alpha, *args, **kwds) |
Confidence interval with equal areas around the median. |
isf(q, *args, **kwds) |
Inverse survival function (inverse of sf) at q of the given RV. |
logcdf(x, *args, **kwds) |
Log of the cumulative distribution function at x of the given RV. |
logpdf(x, *args, **kwds) |
Log of the probability density function at x of the given RV. |
logsf(x, *args, **kwds) |
Log of the survival function of the given RV. |
mean(*args, **kwds) |
Mean of the distribution. |
median(*args, **kwds) |
Median of the distribution. |
moment(n, *args, **kwds) |
n-th order non-central moment of distribution. |
nnlf(theta, x) |
Return negative loglikelihood function. |
nnlf_fr(thetash, x, frmask) |
|
pdf(x, *args, **kwds) |
Probability density function at x of the given RV. |
ppf(q, *args, **kwds) |
Percent point function (inverse of cdf) at q of the given RV. |
rvs(*args, **kwds) |
Random variates of given type. |
sf(x, *args, **kwds) |
Survival function (1 - cdf) at x of the given RV. |
stats(*args, **kwds) |
Some statistics of the given RV. |
std(*args, **kwds) |
Standard deviation of the distribution. |
var(*args, **kwds) |
Variance of the distribution. |
3.3.2.2.1.2. Attributes¶
random_state |
Get or set the RandomState object for generating random variates. |