stats.tests.test_distributions

Test functions for stats module

Module Contents

Functions

_assert_hasattr(a,b,msg=None)
test_api_regression()
check_distribution(dist,args,alpha)
cases_test_all_distributions()
test_all_distributions(dist,args,alpha)
check_vonmises_pdf_periodic(k,l,s,x)
check_vonmises_cdf_periodic(k,l,s,x)
test_vonmises_pdf_periodic()
test_vonmises_line_support()
test_vonmises_numerical()
test_support(dist) gh-6235
test_rvgeneric_std()
TestArgsreduce()
test_540_567()
test_regression_ticket_1316()
test_regression_ticket_1326()
test_regression_tukey_lambda()
test_regression_ticket_1421()
test_nan_arguments_gh_issue_1362()
test_frozen_fit_ticket_1536()
test_regression_ticket_1530()
test_gh_pr_4806()
test_tukeylambda_stats_ticket_1545()
test_poisson_logpmf_ticket_1436()
test_powerlaw_stats() Test the powerlaw stats function.
test_powerlaw_edge()
test_exponpow_edge()
test_gengamma_edge()
test_ksone_fit_freeze()
test_norm_logcdf()
test_levy_cdf_ppf()
test_hypergeom_interval_1802()
test_distribution_too_many_args()
test_ncx2_tails_ticket_955()
test_ncx2_tails_pdf()
test_foldnorm_zero()
test_stats_shapes_argcheck()
test_docstrings()
test_infinite_input()
test_lomax_accuracy()
test_gompertz_accuracy()
test_truncexpon_accuracy()
test_rayleigh_accuracy()
test_genextreme_give_no_warnings() regression test for gh-6219
test_genextreme_entropy()
test_genextreme_sf_isf()
test_burr12_ppf_small_arg()
test_crystalball_function() All values are calculated using the independent implementation of the ROOT framework (see https://root.cern.ch/).
test_crystalball_function_moments() All values are calculated using the pdf formula and the integrate function of Mathematica
test_argus_function()
_assert_hasattr(a, b, msg=None)
test_api_regression()
check_distribution(dist, args, alpha)
cases_test_all_distributions()
test_all_distributions(dist, args, alpha)
check_vonmises_pdf_periodic(k, l, s, x)
check_vonmises_cdf_periodic(k, l, s, x)
test_vonmises_pdf_periodic()
test_vonmises_line_support()
test_vonmises_numerical()
test_support(dist)

gh-6235

class TestRandInt
setup_method()
test_rvs()
test_pdf()
test_cdf()
class TestBinom
setup_method()
test_rvs()
test_pmf()
test_entropy()
test_warns_p0()
class TestBernoulli
setup_method()
test_rvs()
test_entropy()
class TestBradford
test_cdf_ppf()
class TestNBinom
setup_method()
test_rvs()
test_pmf()
class TestGeom
setup_method()
test_rvs()
test_pmf()
test_logpmf()
test_cdf_sf()
test_logcdf_logsf()
test_ppf()
class TestPlanck
setup_method()
test_sf()
test_logsf()
class TestGennorm
test_laplace()
test_norm()
class TestHalfgennorm
test_expon()
test_halfnorm()
test_gennorm()
class TestTruncnorm
setup_method()
test_ppf_ticket1131()
test_isf_ticket1131()
test_gh_2477_small_values()
test_gh_2477_large_values()
test_gh_1489_trac_962_rvs()
class TestHypergeom
setup_method()
test_rvs()
test_precision()
test_args()
test_cdf_above_one()
test_precision2()
test_entropy()
test_logsf()
class TestLoggamma
test_stats()
class TestLogistic
test_cdf_ppf()
test_sf_isf()
test_extreme_values()
class TestLogser
setup_method()
test_rvs()
test_pmf_small_p()
test_mean_small_p()
class TestPareto
test_stats()
test_sf()
class TestGenpareto
test_ab()
test_c0()
test_cm1()
test_x_inf()
test_c_continuity()
test_c_continuity_ppf()
test_c_continuity_isf()
test_cdf_ppf_roundtrip()
test_logsf()
class TestPearson3
setup_method()
test_rvs()
test_pdf()
test_cdf()
class TestKappa4
test_cdf_genpareto()
test_cdf_genextreme()
test_cdf_expon()
test_cdf_gumbel_r()
test_cdf_logistic()
test_cdf_uniform()
test_integers_ctor()
class TestPoisson
setup_method()
test_pmf_basic()
test_mu0()
test_rvs()
test_stats()
class TestZipf
setup_method()
test_rvs()
test_moments()
class TestDLaplace
setup_method()
test_rvs()
test_stats()
test_stats2()
class TestInvGamma
test_invgamma_inf_gh_1866()
test_cdf_ppf()
test_sf_isf()
class TestF
test_f_moments()
test_moments_warnings()
test_stats_broadcast()
test_rvgeneric_std()
class TestRvDiscrete
setup_method()
test_rvs()
test_entropy()
test_pmf()
test_cdf()
test_ppf()
test_cdf_ppf_next()
test_expect()
test_bad_input()
class TestSkewNorm
setup_method()
test_normal()
test_rvs()
test_moments()
class TestExpon
test_zero()
test_tail()
class TestExponNorm
test_moments()
test_extremes_x()
class TestGenExpon
test_pdf_unity_area()
test_cdf_bounds()
class TestExponpow
test_tail()
class TestSkellam
test_pmf()
test_cdf()
class TestLognorm
test_pdf()
test_logcdf()
class TestBeta
test_logpdf()
test_logpdf_ticket_1866()
class TestBetaPrime
test_logpdf()
test_cdf()
class TestGamma
test_pdf()
test_logpdf()
class TestChi2
test_precision()
class TestGumbelL
test_cdf_ppf()
test_logcdf_logsf()
test_sf_isf()
class TestArrayArgument
setup_method()
test_noexception()
class TestDocstring
test_docstrings()
test_no_name_arg()
class TestEntropy
test_entropy_positive()
test_entropy_base()
test_entropy_zero()
test_entropy_2d()
test_entropy_2d_zero()
TestArgsreduce()
class TestFitMethod
setup_method()
test_fit(dist, args, alpha)
test_fix_fit(dist, args, alpha)
test_fix_fit_2args_lognorm()
test_fix_fit_norm()
test_fix_fit_gamma()
test_fix_fit_beta()
test_fshapes()
test_extra_params()
class TestFrozen
setup_method()
test_norm()
test_gamma()
test_regression_ticket_1293()
test_ab()
test_rv_frozen_in_namespace()
test_random_state()
test_pickling()
test_expect()
class TestExpect
test_norm()
test_beta()
test_hypergeom()
test_poisson()
test_genhalflogistic()
test_rice_overflow()
test_logser()
test_skellam()
test_randint()
test_zipf()
test_discrete_kwds()
test_moment()
class TestNct
test_nc_parameter()
test_broadcasting()
test_variance_gh_issue_2401()
test_nct_inf_moments()
class TestRice
test_rice_zero_b()
test_rice_rvs()
class TestErlang
setup_method()
test_erlang_runtimewarning()
class TestRayleigh
test_logpdf()
test_logsf()
class TestExponWeib
test_pdf_logpdf()
test_a_is_1()
test_a_is_1_c_is_1()
class TestWeibull
test_logpdf()
test_with_maxima_distrib()
class TestRdist
test_rdist_cdf_gh1285()
class TestTrapz
test_reduces_to_triang()
test_reduces_to_uniform()
test_cases()
test_trapz_vect()
test_540_567()
test_regression_ticket_1316()
test_regression_ticket_1326()
test_regression_tukey_lambda()
test_regression_ticket_1421()
test_nan_arguments_gh_issue_1362()
test_frozen_fit_ticket_1536()
test_regression_ticket_1530()
test_gh_pr_4806()
test_tukeylambda_stats_ticket_1545()
test_poisson_logpmf_ticket_1436()
test_powerlaw_stats()

Test the powerlaw stats function.

This unit test is also a regression test for ticket 1548.

The exact values are: mean:

mu = a / (a + 1)
variance:
sigma**2 = a / ((a + 2) * (a + 1) ** 2)
skewness:
One formula (see http://en.wikipedia.org/wiki/Skewness) is
gamma_1 = (E[X**3] - 3*mu*E[X**2] + 2*mu**3) / sigma**3

A short calculation shows that E[X**k] is a / (a + k), so gamma_1 can be implemented as

n = a/(a+3) - 3*(a/(a+1))*a/(a+2) + 2*(a/(a+1))**3 d = sqrt(a/((a+2)*(a+1)**2)) ** 3 gamma_1 = n/d

Either by simplifying, or by a direct calculation of mu_3 / sigma**3, one gets the more concise formula:

gamma_1 = -2.0 * ((a - 1) / (a + 3)) * sqrt((a + 2) / a)
kurtosis: (See http://en.wikipedia.org/wiki/Kurtosis)
The excess kurtosis is
gamma_2 = mu_4 / sigma**4 - 3
A bit of calculus and algebra (sympy helps) shows that
mu_4 = 3*a*(3*a**2 - a + 2) / ((a+1)**4 * (a+2) * (a+3) * (a+4))
so
gamma_2 = 3*(3*a**2 - a + 2) * (a+2) / (a*(a+3)*(a+4)) - 3
which can be rearranged to
gamma_2 = 6 * (a**3 - a**2 - 6*a + 2) / (a*(a+3)*(a+4))
test_powerlaw_edge()
test_exponpow_edge()
test_gengamma_edge()
test_ksone_fit_freeze()
test_norm_logcdf()
test_levy_cdf_ppf()
test_hypergeom_interval_1802()
test_distribution_too_many_args()
test_ncx2_tails_ticket_955()
test_ncx2_tails_pdf()
test_foldnorm_zero()
test_stats_shapes_argcheck()
class _distr_gen
_pdf(x, a)
class _distr2_gen
_cdf(x, a)
class _distr3_gen
_pdf(x, a, b)
_cdf(x, a)
class _distr6_gen
_pdf(x, a, b)
_cdf(x, a, b)
class TestSubclassingExplicitShapes
test_correct_shapes()
test_wrong_shapes_1()
test_wrong_shapes_2()
test_shapes_string()
test_shapes_identifiers_1()
test_shapes_identifiers_2()
test_shapes_identifiers_3()
test_shapes_identifiers_nodefaults()
test_shapes_args()
test_shapes_kwargs()
test_shapes_keywords()
test_shapes_signature()
test_shapes_signature_inconsistent()
test_star_args()
test_star_args_2()
test_extra_kwarg()
shapes_empty_string()
class TestSubclassingNoShapes
test_only__pdf()
test_only__cdf()
test_signature_inspection()
test_signature_inspection_2args()
test_signature_inspection_2args_incorrect_shapes()
test_defaults_raise()
test_starargs_raise()
test_kwargs_raise()
test_docstrings()
test_infinite_input()
test_lomax_accuracy()
test_gompertz_accuracy()
test_truncexpon_accuracy()
test_rayleigh_accuracy()
test_genextreme_give_no_warnings()

regression test for gh-6219

test_genextreme_entropy()
test_genextreme_sf_isf()
test_burr12_ppf_small_arg()
test_crystalball_function()

All values are calculated using the independent implementation of the ROOT framework (see https://root.cern.ch/). Corresponding ROOT code is given in the comments.

test_crystalball_function_moments()

All values are calculated using the pdf formula and the integrate function of Mathematica

test_argus_function()
class TestHistogram
setup_method()
test_pdf()
test_cdf_ppf()
test_rvs()
test_munp()
test_entropy()