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


Python special.zeta方法代码示例

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


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

示例1: zeta

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def zeta(x, q):
    """Zeta function.

    Differentiable only with respect to q

    .. note::
       Forward computation in CPU can not be done if
       `SciPy <https://www.scipy.org/>`_ is not available.

    Args:
        x (:class:`~chainer.Variable` or :ref:`ndarray`): Input variable.
        q (:class:`~chainer.Variable` or :ref:`ndarray`): Input variable.

    Returns:
        ~chainer.Variable: Output variable.
    """
    return Zeta(x).apply((q,))[0] 
开发者ID:chainer,项目名称:chainer,代码行数:19,代码来源:zeta.py

示例2: _munp

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _munp(self, n):
        if n == 1.0:
            return np.log(2) + np.euler_gamma
        elif n == 2.0:
            return np.pi**2 / 2 + (np.log(2) + np.euler_gamma)**2
        elif n == 3.0:
            tmp1 = 1.5 * np.pi**2 * (np.log(2)+np.euler_gamma)
            tmp2 = (np.log(2)+np.euler_gamma)**3
            tmp3 = 14 * sc.zeta(3)
            return tmp1 + tmp2 + tmp3
        elif n == 4.0:
            tmp1 = 4 * 14 * sc.zeta(3) * (np.log(2) + np.euler_gamma)
            tmp2 = 3 * np.pi**2 * (np.log(2) + np.euler_gamma)**2
            tmp3 = (np.log(2) + np.euler_gamma)**4
            tmp4 = 7 * np.pi**4 / 4
            return tmp1 + tmp2 + tmp3 + tmp4
        else:
            # return generic for higher moments
            # return rv_continuous._mom1_sc(self, n, b)
            return self._mom1_sc(n) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:22,代码来源:_continuous_distns.py

示例3: _stats

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _stats(self, c):
        mu = _EULER + sc.psi(c)
        mu2 = np.pi*np.pi/6.0 + sc.zeta(2, c)
        g1 = -2*sc.zeta(3, c) + 2*_ZETA3
        g1 /= np.power(mu2, 1.5)
        g2 = np.pi**4/15.0 + 6*sc.zeta(4, c)
        g2 /= mu2**2.0
        return mu, mu2, g1, g2 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:10,代码来源:_continuous_distns.py

示例4: _munp

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _munp(self, n):
        if n == 1:
            return 2*np.log(2)
        if n == 2:
            return np.pi*np.pi/3.0
        if n == 3:
            return 9*_ZETA3
        if n == 4:
            return 7*np.pi**4 / 15.0
        return 2*(1-pow(2.0, 1-n))*sc.gamma(n+1)*sc.zeta(n, 1) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,代码来源:_continuous_distns.py

示例5: _preprocess

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _preprocess(self, x, skew):
        # The real 'loc' and 'scale' are handled in the calling pdf(...). The
        # local variables 'loc' and 'scale' within pearson3._pdf are set to
        # the defaults just to keep them as part of the equations for
        # documentation.
        loc = 0.0
        scale = 1.0

        # If skew is small, return _norm_pdf. The divide between pearson3
        # and norm was found by brute force and is approximately a skew of
        # 0.000016.  No one, I hope, would actually use a skew value even
        # close to this small.
        norm2pearson_transition = 0.000016

        ans, x, skew = np.broadcast_arrays([1.0], x, skew)
        ans = ans.copy()

        # mask is True where skew is small enough to use the normal approx.
        mask = np.absolute(skew) < norm2pearson_transition
        invmask = ~mask

        beta = 2.0 / (skew[invmask] * scale)
        alpha = (scale * beta)**2
        zeta = loc - alpha / beta

        transx = beta * (x[invmask] - zeta)
        return ans, x, transx, mask, invmask, beta, alpha, zeta 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:29,代码来源:_continuous_distns.py

示例6: _pdf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _pdf(self, x, skew):
        # pearson3.pdf(x, skew) = abs(beta) / gamma(alpha) *
        #     (beta * (x - zeta))**(alpha - 1) * exp(-beta*(x - zeta))
        # Do the calculation in _logpdf since helps to limit
        # overflow/underflow problems
        ans = np.exp(self._logpdf(x, skew))
        if ans.ndim == 0:
            if np.isnan(ans):
                return 0.0
            return ans
        ans[np.isnan(ans)] = 0.0
        return ans 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:14,代码来源:_continuous_distns.py

示例7: _rvs

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _rvs(self, skew):
        skew = broadcast_to(skew, self._size)
        ans, _, _, mask, invmask, beta, alpha, zeta = (
            self._preprocess([0], skew))

        nsmall = mask.sum()
        nbig = mask.size - nsmall
        ans[mask] = self._random_state.standard_normal(nsmall)
        ans[invmask] = (self._random_state.standard_gamma(alpha, nbig)/beta +
                        zeta)

        if self._size == ():
            ans = ans[0]
        return ans 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:16,代码来源:_continuous_distns.py

示例8: _ppf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _ppf(self, q, skew):
        ans, q, _, mask, invmask, beta, alpha, zeta = (
            self._preprocess(q, skew))
        ans[mask] = _norm_ppf(q[mask])
        ans[invmask] = sc.gammaincinv(alpha, q[invmask])/beta + zeta
        return ans 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:8,代码来源:_continuous_distns.py

示例9: _pmf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _pmf(self, k, a):
        Pk = 1.0 / special.zeta(a, 1) / k**a
        return Pk 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:5,代码来源:_discrete_distns.py

示例10: _munp

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def _munp(self, n, a):
        return _lazywhere(
            a > n + 1, (a, n),
            lambda a, n: special.zeta(a - n, 1) / special.zeta(a, 1),
            np.inf) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:7,代码来源:_discrete_distns.py

示例11: test_zeta

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def test_zeta(self):
        assert_mpmath_equal(sc.zeta,
                            _exception_to_nan(mpmath.zeta),
                            [Arg(a=1, b=1e10, inclusive_a=False),
                             Arg(a=0, inclusive_a=False)]) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_mpmath.py

示例12: label

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def label(self):
        return 'zeta' 
开发者ID:chainer,项目名称:chainer,代码行数:4,代码来源:zeta.py

示例13: forward_cpu

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def forward_cpu(self, inputs):
        q, = inputs
        global _zeta_cpu
        if _zeta_cpu is None:
            try:
                from scipy import special
                _zeta_cpu = special.zeta
            except ImportError:
                raise ImportError('Scipy is not available. Forward computation'
                                  ' of zeta cannot be done.')
        self.retain_inputs((0,))
        return utils.force_array(_zeta_cpu(self._x, q), dtype=q.dtype), 
开发者ID:chainer,项目名称:chainer,代码行数:14,代码来源:zeta.py

示例14: forward_gpu

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def forward_gpu(self, inputs):
        q, = inputs
        self.retain_inputs((0,))
        return utils.force_array(
            cuda.cupyx.scipy.special.zeta(self._x, q), dtype=q.dtype), 
开发者ID:chainer,项目名称:chainer,代码行数:7,代码来源:zeta.py

示例15: backward

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import zeta [as 别名]
def backward(self, indexes, gy):
        q, = self.get_retained_inputs()
        return gy[0] * -self._x * zeta(self._x + 1, q), 
开发者ID:chainer,项目名称:chainer,代码行数:5,代码来源:zeta.py


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