当前位置: 首页>>代码示例>>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;未经允许,请勿转载。