當前位置: 首頁>>代碼示例>>Python>>正文


Python misc.factorial方法代碼示例

本文整理匯總了Python中scipy.misc.factorial方法的典型用法代碼示例。如果您正苦於以下問題:Python misc.factorial方法的具體用法?Python misc.factorial怎麽用?Python misc.factorial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.misc的用法示例。


在下文中一共展示了misc.factorial方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _K_T_xs

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _K_T_xs(self, temperature, volume, params): # K_T_xs, eq. 3.20 of de Koker thesis
        f = self._finite_strain(temperature, volume, params)
        theta = self._theta(temperature, volume, params)
        K_ToverV=0.
        for i in range(len(params['a'])):
            ifact=factorial(i, exact=False)
            for j in range(len(params['a'][0])):
                if i > 0:
                    jfact=factorial(j, exact=False)
                    prefactor = float(i) * params['a'][i][j] \
                        * np.power(theta, float(j)) / ifact / jfact 
                    K_ToverV += prefactor*self._d2fdV2(temperature, volume, params) \
                        * np.power(f, float(i-1))
                if i > 1:
                    dfdV = self._dfdV(temperature, volume, params)
                    K_ToverV += prefactor * dfdV * dfdV \
                        * float(i-1) * np.power(f, float(i-2))
        return volume*K_ToverV 
開發者ID:geodynamics,項目名稱:burnman,代碼行數:20,代碼來源:dks_liquid.py

示例2: _alphaK_T_xs

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _alphaK_T_xs(self, temperature, volume, params): # eq. 3.21 of de Koker thesis
        f = self._finite_strain(temperature, volume, params)
        theta = self._theta(temperature, volume, params)
        sum_factors = 0.
        for i in range(len(params['a'])):
            ifact=factorial(i, exact=False)
            if i > 0:
                for j in range(len(params['a'][0])):
                    if j > 0:
                        jfact=factorial(j, exact=False)
                        sum_factors += float(i)*float(j)*params['a'][i][j] \
                            * np.power(f, float(i-1)) * np.power(theta, float(j-1)) \
                            / ifact / jfact
                            
        return -self._dfdV(temperature, volume, params) \
            * self._dthetadT(temperature, volume, params) \
            * sum_factors 
開發者ID:geodynamics,項目名稱:burnman,代碼行數:19,代碼來源:dks_liquid.py

示例3: normal_reference_constant

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def normal_reference_constant(self):
        """
        Constant used for silverman normal reference asymtotic bandwidth
        calculation.

        C  = 2((pi^(1/2)*(nu!)^3 R(k))/(2nu(2nu)!kap_nu(k)^2))^(1/(2nu+1))
        nu = kernel order
        kap_nu = nu'th moment of kernel
        R = kernel roughness (square of L^2 norm)

        Note: L2Norm property returns square of norm.
        """
        nu = self._order

        if not nu == 2:
            msg = "Only implemented for second order kernels"
            raise NotImplementedError(msg)

        if self._normal_reference_constant is None:
            C = np.pi**(.5) * factorial(nu)**3 * self.L2Norm
            C /= (2 * nu * factorial(2 * nu) * self.moments(nu)**2)
            C = 2*C**(1.0/(2*nu+1))
            self._normal_reference_constant = C

        return self._normal_reference_constant 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:27,代碼來源:kernels.py

示例4: _compute_coefs_pdf

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _compute_coefs_pdf(self, cum):
        # scale cumulants by \sigma
        mu, sigma = cum[0], np.sqrt(cum[1])
        lam = np.asarray(cum)
        for j, l in enumerate(lam):
            lam[j] /= cum[1]**j

        coef = np.zeros(lam.size * 3 - 5)
        coef[0] = 1.
        for s in range(lam.size - 2):
            for p in _faa_di_bruno_partitions(s+1):
                term = sigma**(s+1)
                for (m, k) in p:
                    term *= np.power(lam[m+1] / factorial(m+2), k) / factorial(k)
                r = sum(k for (m, k) in p)
                coef[s + 1 + 2*r] += term
        return coef, mu, sigma 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:19,代碼來源:edgeworth.py

示例5: nloglikeobs

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def nloglikeobs(self, params):
        """
        Loglikelihood of Poisson model

        Parameters
        ----------
        params : array-like
            The parameters of the model.

        Returns
        -------
        The log likelihood of the model evaluated at `params`

        Notes
        --------
        .. math:: \\ln L=\\sum_{i=1}^{n}\\left[-\\lambda_{i}+y_{i}x_{i}^{\\prime}\\beta-\\ln y_{i}!\\right]
        """
        XB = np.dot(self.exog, params)
        endog = self.endog
        return np.exp(XB) -  endog*XB + np.log(factorial(endog)) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:22,代碼來源:count.py

示例6: __init__

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def __init__(self, xi, yi, axis=0):
        _Interpolator1DWithDerivatives.__init__(self, xi, yi, axis)

        self.xi = np.asarray(xi)
        self.yi = self._reshape_yi(yi)
        self.n, self.r = self.yi.shape

        c = np.zeros((self.n+1, self.r), dtype=self.dtype)
        c[0] = self.yi[0]
        Vk = np.zeros((self.n, self.r), dtype=self.dtype)
        for k in xrange(1,self.n):
            s = 0
            while s <= k and xi[k-s] == xi[k]:
                s += 1
            s -= 1
            Vk[0] = self.yi[k]/float(factorial(s))
            for i in xrange(k-s):
                if xi[i] == xi[k]:
                    raise ValueError("Elements if `xi` can't be equal.")
                if s == 0:
                    Vk[i+1] = (c[i]-Vk[i])/(xi[i]-xi[k])
                else:
                    Vk[i+1] = (Vk[i+1]-Vk[i])/(xi[i]-xi[k])
            c[k] = Vk[k-s]
        self.c = c 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:27,代碼來源:polyint.py

示例7: get_K

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def get_K(x, n):
    """
    It computes the polinomials K needed for Kirkwood-1934 solutions.
    K_n(x) in Equation 4 in Kirkwood 1934.

    Arguments
    ----------
    x: float, evaluation point of K.
    n: int, number of terms desired in the expansion.

    Returns
    --------
    K: float, polinomials K.
    """

    K = 0.
    n_fact = factorial(n)
    n_fact2 = factorial(2 * n)
    for s in range(n + 1):
        K += 2**s * n_fact * factorial(2 * n - s) / (factorial(s) * n_fact2 *
                                                     factorial(n - s)) * x**s

    return K 
開發者ID:pygbe,項目名稱:pygbe,代碼行數:25,代碼來源:an_solution.py

示例8: nloglikeobs

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def nloglikeobs(self, params):
        """
        Loglikelihood of Poisson model

        Parameters
        ----------
        params : array-like
            The parameters of the model.

        Returns
        -------
        The log likelihood of the model evaluated at `params`

        Notes
        --------
        .. math :: \\ln L=\\sum_{i=1}^{n}\\left[-\\lambda_{i}+y_{i}x_{i}^{\\prime}\\beta-\\ln y_{i}!\\right]
        """
        XB = np.dot(self.exog, params)
        endog = self.endog
        return np.exp(XB) -  endog*XB + np.log(factorial(endog)) 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:22,代碼來源:count.py

示例9: _F_xs

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _F_xs(self, temperature, volume, params): # F_xs, eq. S2
        f = self._finite_strain(temperature, volume, params)
        theta = self._theta(temperature, volume, params)
        energy = 0.
        for i in range(len(params['a'])):
            ifact=factorial(i, exact=False)
            for j in range(len(params['a'][0])):
                jfact=factorial(j, exact=False)
                energy += params['a'][i][j]*np.power(f, i)*np.power(theta, j)/ifact/jfact         
        return energy 
開發者ID:geodynamics,項目名稱:burnman,代碼行數:12,代碼來源:dks_liquid.py

示例10: _S_xs

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _S_xs(self, temperature, volume, params): # F_xs, eq. 3.18
        f = self._finite_strain(temperature, volume, params)
        theta = self._theta(temperature, volume, params)
        entropy = 0.
        for i in range(len(params['a'])):
            ifact = factorial(i, exact=False)
            for j in range(len(params['a'][0])):
                if j > 0:
                    jfact = factorial(j, exact=False)
                    entropy += j*params['a'][i][j]*np.power(f, i)*np.power(theta, j-1.)/ifact/jfact         
        return -self._dthetadT(temperature, volume, params)*entropy 
開發者ID:geodynamics,項目名稱:burnman,代碼行數:13,代碼來源:dks_liquid.py

示例11: _P_xs

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _P_xs(self, temperature, volume, params): # P_xs, eq. 3.17 of de Koker thesis
        f = self._finite_strain(temperature, volume, params)
        theta = self._theta(temperature, volume, params)
        pressure=0.
        for i in range(len(params['a'])):
            ifact=factorial(i, exact=False)
            if i > 0:
                for j in range(len(params['a'][0])):
                    jfact=factorial(j, exact=False)
                    pressure += float(i)*params['a'][i][j]*np.power(f, float(i)-1.)*np.power(theta, float(j))/ifact/jfact
        return -self._dfdV(temperature, volume, params)*pressure 
開發者ID:geodynamics,項目名稱:burnman,代碼行數:13,代碼來源:dks_liquid.py

示例12: _chi2_cumulant

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _chi2_cumulant(n, df):
    assert n > 0
    return 2**(n-1) * factorial(n - 1) * df 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:5,代碼來源:test_edgeworth.py

示例13: cumulant_from_moments

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def cumulant_from_moments(momt, n):
    """Compute n-th cumulant given moments.

    Parameters
    ----------
    momt: array_like
        `momt[j]` contains `(j+1)`-th moment.
        These can be raw moments around zero, or central moments
        (in which case, `momt[0]` == 0).
    n: integer
        which cumulant to calculate (must be >1)

    Returns
    -------
    kappa: float
        n-th cumulant.

    """
    if n < 1:
        raise ValueError("Expected a positive integer. Got %s instead." % n)
    if len(momt) < n:
        raise ValueError("%s-th cumulant requires %s moments, "
                         "only got %s." % (n, n, len(momt)))
    kappa = 0.
    for p in _faa_di_bruno_partitions(n):
        r = sum(k for (m, k) in p)
        term = (-1)**(r - 1) * factorial(r - 1)
        for (m, k) in p:
            term *= np.power(momt[m - 1] / factorial(m), k) / factorial(k)
        kappa += term
    kappa *= factorial(n)
    return kappa

## copied from scipy.stats.distributions to avoid the overhead of
## the public methods 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:37,代碼來源:edgeworth.py

示例14: _evaluate_derivatives

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def _evaluate_derivatives(self, x, der=None):
        n = self.n
        r = self.r

        if der is None:
            der = self.n
        pi = np.zeros((n, len(x)))
        w = np.zeros((n, len(x)))
        pi[0] = 1
        p = np.zeros((len(x), self.r))
        p += self.c[0,np.newaxis,:]

        for k in xrange(1,n):
            w[k-1] = x - self.xi[k-1]
            pi[k] = w[k-1]*pi[k-1]
            p += pi[k,:,np.newaxis]*self.c[k]

        cn = np.zeros((max(der,n+1), len(x), r), dtype=self.dtype)
        cn[:n+1,:,:] += self.c[:n+1,np.newaxis,:]
        cn[0] = p
        for k in xrange(1,n):
            for i in xrange(1,n-k+1):
                pi[i] = w[k+i-1]*pi[i-1]+pi[i]
                cn[k] = cn[k]+pi[i,:,np.newaxis]*cn[k+i]
            cn[k] *= factorial(k)

        cn[n,:,:] = 0
        return cn[:der] 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:30,代碼來源:polyint.py

示例15: combine_pvalues

# 需要導入模塊: from scipy import misc [as 別名]
# 或者: from scipy.misc import factorial [as 別名]
def combine_pvalues(x):
    #k=x.prod()
    k= np.exp(np.log(x).sum())
    p=0
    for i in range(len(x)):	
        p+=np.power(-np.log(k),i)/factorial(i)

    #print k --i
    #print p
    return k*p 
開發者ID:lucapinello,項目名稱:Haystack,代碼行數:12,代碼來源:haystack_motifs_CORE.py


注:本文中的scipy.misc.factorial方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。