示例#1
0
def test_random_state_property():
    scale = np.eye(3)
    scale[0, 1] = 0.5
    scale[1, 0] = 0.5
    dists = [[multivariate_normal, ()], [dirichlet, (np.array([1.]), )],
             [wishart, (10, scale)], [invwishart, (10, scale)]]
    for distfn, args in dists:
        check_random_state_property(distfn, args)
示例#2
0
def test_random_state_property():
    scale = np.eye(3)
    scale[0,1] = 0.5
    scale[1,0] = 0.5
    dists = [
        [multivariate_normal, ()],
        [dirichlet, (np.array([1.]), )],
        [wishart, (10, scale)],
        [invwishart, (10, scale)]
    ]
    for distfn, args in dists:
        check_random_state_property(distfn, args)
示例#3
0
    def check(distname, arg):
        distfn = getattr(stats, distname)
        np.random.seed(765456)
        sn = 500
        rvs = distfn.rvs(size=sn, *arg)
        sm = rvs.mean()
        sv = rvs.var()
        m, v = distfn.stats(*arg)
        check_sample_meanvar_(distfn, arg, m, v, sm, sv, sn,
                              distname + 'sample mean test')
        check_cdf_ppf(distfn, arg, distname)
        check_sf_isf(distfn, arg, distname)
        check_pdf(distfn, arg, distname)
        check_pdf_logpdf(distfn, arg, distname)
        check_cdf_logcdf(distfn, arg, distname)
        check_sf_logsf(distfn, arg, distname)
        # check_oth(distfn, arg # is still missing)

        alpha = 0.01
        check_distribution_rvs(distname, arg, alpha, rvs)

        locscale_defaults = (0, 1)
        meths = [
            distfn.pdf, distfn.logpdf, distfn.cdf, distfn.logcdf, distfn.logsf
        ]
        # make sure arguments are within support
        x = 0.5
        if distname == 'invweibull':
            arg = (1, )
        elif distname == 'ksone':
            arg = (3, )
        check_named_args(distfn, x, arg, locscale_defaults, meths)
        check_random_state_property(distfn, arg)
        check_pickling(distfn, arg)

        # Entropy
        if distname not in ['ksone', 'kstwobign']:
            check_entropy(distfn, arg, distname)

        if distfn.numargs == 0:
            check_vecentropy(distfn, arg)
        if (distfn.__class__._entropy != stats.rv_continuous._entropy
                and distname != 'vonmises'):
            check_private_entropy(distfn, arg, stats.rv_continuous)

        check_edge_support(distfn, arg)

        check_meth_dtype(distfn, arg, meths)
        check_ppf_dtype(distfn, arg)

        if distname not in fails_cmplx:
            check_cmplx_deriv(distfn, arg)
示例#4
0
    def check(distname, arg):
        try:
            distfn = getattr(stats, distname)
        except TypeError:
            distfn = distname
            distname = 'rv_histogram_instance'
        np.random.seed(765456)
        sn = 500
        rvs = distfn.rvs(size=sn, *arg)
        sm = rvs.mean()
        sv = rvs.var()
        m, v = distfn.stats(*arg)

        check_sample_meanvar_(distfn, arg, m, v, sm, sv, sn,
                              distname + 'sample mean test')
        check_cdf_ppf(distfn, arg, distname)
        check_sf_isf(distfn, arg, distname)
        check_pdf(distfn, arg, distname)
        check_pdf_logpdf(distfn, arg, distname)
        check_cdf_logcdf(distfn, arg, distname)
        check_sf_logsf(distfn, arg, distname)

        alpha = 0.01
        if distname == 'rv_histogram_instance':
            check_distribution_rvs(distfn.cdf, arg, alpha, rvs)
        else:
            check_distribution_rvs(distname, arg, alpha, rvs)

        locscale_defaults = (0, 1)
        meths = [
            distfn.pdf, distfn.logpdf, distfn.cdf, distfn.logcdf, distfn.logsf
        ]
        # make sure arguments are within support
        spec_x = {
            'frechet_l': -0.5,
            'weibull_max': -0.5,
            'levy_l': -0.5,
            'pareto': 1.5,
            'tukeylambda': 0.3,
            'rv_histogram_instance': 5.0
        }
        x = spec_x.get(distname, 0.5)
        check_named_args(distfn, x, arg, locscale_defaults, meths)
        check_random_state_property(distfn, arg)
        check_pickling(distfn, arg)

        # Entropy
        check_entropy(distfn, arg, distname)

        if distfn.numargs == 0:
            check_vecentropy(distfn, arg)

        if distfn.__class__._entropy != stats.rv_continuous._entropy:
            check_private_entropy(distfn, arg, stats.rv_continuous)

        check_edge_support(distfn, arg)

        check_meth_dtype(distfn, arg, meths)
        check_ppf_dtype(distfn, arg)

        if distname not in fails_cmplx:
            check_cmplx_deriv(distfn, arg)

        if distname != 'truncnorm':
            check_ppf_private(distfn, arg, distname)
示例#5
0
def test_levy_stable_random_state_property():
    # levy_stable only implements rvs(), so it is skipped in the
    # main loop in test_cont_basic(). Here we apply just the test
    # check_random_state_property to levy_stable.
    check_random_state_property(stats.levy_stable, (0.5, 0.1))
def test_levy_stable_random_state_property():
    # levy_stable only implements rvs(), so it is skipped in the
    # main loop in test_cont_basic(). Here we apply just the test
    # check_random_state_property to levy_stable.
    check_random_state_property(stats.levy_stable, (0.5, 0.1))