當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。