当前位置: 首页>>代码示例>>Python>>正文


Python stats.rv_continuous方法代码示例

本文整理汇总了Python中scipy.stats.rv_continuous方法的典型用法代码示例。如果您正苦于以下问题:Python stats.rv_continuous方法的具体用法?Python stats.rv_continuous怎么用?Python stats.rv_continuous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.stats的用法示例。


在下文中一共展示了stats.rv_continuous方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_no_name_arg

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_no_name_arg(self):
        # If name is not given, construction shouldn't fail.  See #1508.
        stats.rv_continuous()
        stats.rv_discrete() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:test_distributions.py

示例2: test_shapes_signature

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_shapes_signature(self):
        # test explicit shapes which agree w/ the signature of _pdf
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x, a):
                return stats.norm._pdf(x) * a

        dist = _dist_gen(shapes='a')
        assert_equal(dist.pdf(0.5, a=2), stats.norm.pdf(0.5)*2) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_distributions.py

示例3: test_shapes_signature_inconsistent

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_shapes_signature_inconsistent(self):
        # test explicit shapes which do not agree w/ the signature of _pdf
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x, a):
                return stats.norm._pdf(x) * a

        dist = _dist_gen(shapes='a, b')
        assert_raises(TypeError, dist.pdf, 0.5, **dict(a=1, b=2)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_distributions.py

示例4: test_star_args

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_star_args(self):
        # test _pdf with only starargs
        # NB: **kwargs of pdf will never reach _pdf
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x, *args):
                extra_kwarg = args[0]
                return stats.norm._pdf(x) * extra_kwarg

        dist = _dist_gen(shapes='extra_kwarg')
        assert_equal(dist.pdf(0.5, extra_kwarg=33), stats.norm.pdf(0.5)*33)
        assert_equal(dist.pdf(0.5, 33), stats.norm.pdf(0.5)*33)
        assert_raises(TypeError, dist.pdf, 0.5, **dict(xxx=33)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:test_distributions.py

示例5: test_star_args_2

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_star_args_2(self):
        # test _pdf with named & starargs
        # NB: **kwargs of pdf will never reach _pdf
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x, offset, *args):
                extra_kwarg = args[0]
                return stats.norm._pdf(x) * extra_kwarg + offset

        dist = _dist_gen(shapes='offset, extra_kwarg')
        assert_equal(dist.pdf(0.5, offset=111, extra_kwarg=33),
                     stats.norm.pdf(0.5)*33 + 111)
        assert_equal(dist.pdf(0.5, 111, 33),
                     stats.norm.pdf(0.5)*33 + 111) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:test_distributions.py

示例6: shapes_empty_string

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def shapes_empty_string(self):
        # shapes='' is equivalent to shapes=None
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x):
                return stats.norm.pdf(x)

        dist = _dist_gen(shapes='')
        assert_equal(dist.pdf(0.5), stats.norm.pdf(0.5)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_distributions.py

示例7: test_defaults_raise

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_defaults_raise(self):
        # default arguments should raise
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x, a=42):
                return 42
        assert_raises(TypeError, _dist_gen, **dict(name='dummy')) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_distributions.py

示例8: test_starargs_raise

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_starargs_raise(self):
        # without explicit shapes, *args are not allowed
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x, a, *args):
                return 42
        assert_raises(TypeError, _dist_gen, **dict(name='dummy')) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_distributions.py

示例9: test_kwargs_raise

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_kwargs_raise(self):
        # without explicit shapes, **kwargs are not allowed
        class _dist_gen(stats.rv_continuous):
            def _pdf(self, x, a, **kwargs):
                return 42
        assert_raises(TypeError, _dist_gen, **dict(name='dummy')) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_distributions.py

示例10: test_docstrings

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_docstrings():
    badones = [',\s*,', '\(\s*,', '^\s*:']
    for distname in stats.__all__:
        dist = getattr(stats, distname)
        if isinstance(dist, (stats.rv_discrete, stats.rv_continuous)):
            for regex in badones:
                assert_( re.search(regex, dist.__doc__) is None) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:9,代码来源:test_distributions.py

示例11: test_cdf

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_cdf(self):
        # regression test for gh-4030: Implementation of
        # scipy.stats.betaprime.cdf()
        x = stats.betaprime.cdf(0, 0.2, 0.3)
        assert_equal(x, 0.0)

        alpha, beta = 267, 1472
        x = np.array([0.2, 0.5, 0.6])
        cdfs = stats.betaprime.cdf(x, alpha, beta)
        assert_(np.isfinite(cdfs).all())

        # check the new cdf implementation vs generic one:
        gen_cdf = stats.rv_continuous._cdf_single
        cdfs_g = [gen_cdf(stats.betaprime, val, alpha, beta) for val in x]
        assert_allclose(cdfs, cdfs_g, atol=0, rtol=2e-12) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:17,代码来源:test_distributions.py

示例12: test_extra_kwarg

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def test_extra_kwarg(self):
        # **kwargs to _pdf are ignored.
        # this is a limitation of the framework (_pdf(x, *goodargs))
        class _distr_gen(stats.rv_continuous):
            def _pdf(self, x, *args, **kwargs):
                # _pdf should handle *args, **kwargs itself.  Here "handling"
                # is ignoring *args and looking for ``extra_kwarg`` and using
                # that.
                extra_kwarg = kwargs.pop('extra_kwarg', 1)
                return stats.norm._pdf(x) * extra_kwarg

        dist = _distr_gen(shapes='extra_kwarg')
        assert_equal(dist.pdf(1, extra_kwarg=3), stats.norm.pdf(1)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:15,代码来源:test_distributions.py

示例13: __init__

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def __init__(self, rv_mixed):
        self.rv_mixed = rv_mixed
        self.is_continuous = isinstance(rv_mixed.dist, rv_continuous) 
开发者ID:asnelt,项目名称:mixedvines,代码行数:5,代码来源:marginal.py

示例14: _fit_parametric_family

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def _fit_parametric_family(dist: stats.rv_continuous, sample: np.ndarray) -> Tuple:
    if dist == stats.multivariate_normal:
        # has no fit method...
        return np.mean(sample, axis=0), np.cov(sample.T, ddof=1)

    if dist == stats.t:
        fit_kwd = {"fscale": 1}
    elif dist in {stats.f, stats.beta}:
        fit_kwd = {"floc": 0, "fscale": 1}
    elif dist in (stats.gamma, stats.lognorm, stats.invgauss, stats.pareto):
        fit_kwd = {"floc": 0}
    else:
        fit_kwd = {}

    return dist.fit(sample, **fit_kwd) 
开发者ID:dsaxton,项目名称:resample,代码行数:17,代码来源:bootstrap.py

示例15: dist_gen

# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import rv_continuous [as 别名]
def dist_gen(pdf_in=None, cdf_in=None, ppf_in=None, **kwargs):
    """Distribution Factory.

    Parameters
    ----------
    pdf_in : :any:`callable` or :any:`None`, optional
        Proprobability distribution function of the given distribution, that
        takes a single argument
        Default: ``None``
    cdf_in : :any:`callable` or :any:`None`, optional
        Cumulative distribution function of the given distribution, that
        takes a single argument
        Default: ``None``
    ppf_in : :any:`callable` or :any:`None`, optional
        Percent point function of the given distribution, that
        takes a single argument
        Default: ``None``
    **kwargs
        Keyword-arguments forwarded to :any:`scipy.stats.rv_continuous`.

    Returns
    -------
    dist : :class:`scipy.stats.rv_continuous`
        The constructed distribution.

    Notes
    -----
    At least pdf or cdf needs to be given.
    """
    if ppf_in is None:
        if pdf_in is not None and cdf_in is None:
            return DistPdf(pdf_in, **kwargs)
        if pdf_in is None and cdf_in is not None:
            return DistCdf(cdf_in, **kwargs)
        if pdf_in is not None and cdf_in is not None:
            return DistPdfCdf(pdf_in, cdf_in, **kwargs)
        raise ValueError("Either pdf or cdf must be given")
    else:
        if pdf_in is not None and cdf_in is None:
            return DistPdfPpf(pdf_in, ppf_in, **kwargs)
        if pdf_in is None and cdf_in is not None:
            return DistCdfPpf(cdf_in, ppf_in, **kwargs)
        if pdf_in is not None and cdf_in is not None:
            return DistPdfCdfPpf(pdf_in, cdf_in, ppf_in, **kwargs)
        raise ValueError("pdf or cdf must be given along with the ppf") 
开发者ID:GeoStat-Framework,项目名称:GSTools,代码行数:47,代码来源:tools.py


注:本文中的scipy.stats.rv_continuous方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。