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


Python norm.cdf方法代码示例

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


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

示例1: _get_scaler_function

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def _get_scaler_function(scaler_algo):
        scaler = None
        if scaler_algo == 'normcdf':
            scaler = lambda x: norm.cdf(x, x.mean(), x.std())
        elif scaler_algo == 'lognormcdf':
            scaler = lambda x: norm.cdf(np.log(x), np.log(x).mean(), np.log(x).std())
        elif scaler_algo == 'percentile':
            scaler = lambda x: rankdata(x).astype(np.float64) / len(x)
        elif scaler_algo == 'percentiledense':
            scaler = lambda x: rankdata(x, method='dense').astype(np.float64) / len(x)
        elif scaler_algo == 'ecdf':
            from statsmodels.distributions import ECDF
            scaler = lambda x: ECDF(x)
        elif scaler_algo == 'none':
            scaler = lambda x: x
        else:
            raise InvalidScalerException("Invalid scaler alogrithm.  Must be either percentile or normcdf.")
        return scaler 
开发者ID:JasonKessler,项目名称:scattertext,代码行数:20,代码来源:ScaledFScore.py

示例2: get_p_vals

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def get_p_vals(self, X):
		'''
		Imputes p-values from the Z-scores of `ScaledFScore` scores.  Assuming incorrectly
		that the scaled f-scores are normally distributed.

		Parameters
		----------
		X : np.array
			Array of word counts, shape (N, 2) where N is the vocab size.  X[:,0] is the
			positive class, while X[:,1] is the negative class.

		Returns
		-------
		np.array of p-values

		'''
		z_scores = ScaledFZScore(self.scaler_algo, self.beta).get_scores(X[:,0], X[:,1])
		return norm.cdf(z_scores) 
开发者ID:JasonKessler,项目名称:scattertext,代码行数:20,代码来源:ScaledFScoreSignificance.py

示例3: cdf

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def cdf(self, y, f):
        r"""
        Cumulative density function of the likelihood.

        Parameters
        ----------
        y: ndarray
            query quantiles, i.e.\  :math:`P(Y \leq y)`.
        f: ndarray
            latent function from the GLM prior (:math:`\mathbf{f} =
            \boldsymbol\Phi \mathbf{w}`)

        Returns
        -------
        cdf: ndarray
            Cumulative density function evaluated at y.
        """
        return bernoulli.cdf(y, expit(f)) 
开发者ID:NICTA,项目名称:revrand,代码行数:20,代码来源:likelihoods.py

示例4: test_shapes

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def test_shapes():

    N = 100
    y = np.ones(N)
    f = np.ones(N) * 2

    assert_shape = lambda x: x.shape == (N,)
    assert_args = lambda out, args: \
        all([o.shape == a.shape if not np.isscalar(a) else np.isscalar(o)
             for o, a in zip(out, args)])

    for like, args in zip(likelihoods, likelihood_args):

        lobj = like()
        assert_shape(lobj.loglike(y, f, *args))
        assert_shape(lobj.Ey(f, *args))
        assert_shape(lobj.df(y, f, *args))
        assert_shape(lobj.cdf(y, f, *args))
        assert_args(lobj.dp(y, f, *args), args) 
开发者ID:NICTA,项目名称:revrand,代码行数:21,代码来源:test_likelihoods.py

示例5: test_bernoulli

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def test_bernoulli():

    # Test we can at match a Bernoulli distribution from scipy

    p = 0.5
    dist = lk.Bernoulli()

    x = np.array([0, 1])

    p1 = bernoulli.logpmf(x, p)
    p2 = dist.loglike(x, p)

    np.allclose(p1, p2)

    p1 = bernoulli.cdf(x, p)
    p2 = dist.cdf(x, p)

    np.allclose(p1, p2) 
开发者ID:NICTA,项目名称:revrand,代码行数:20,代码来源:test_likelihoods.py

示例6: test_binom

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def test_binom():

    # Test we can at match a Binomial distribution from scipy

    p = 0.5
    n = 5
    dist = lk.Binomial()

    x = np.random.randint(low=0, high=n, size=(10,))

    p1 = binom.logpmf(x, p=p, n=n)
    p2 = dist.loglike(x, p, n)

    np.allclose(p1, p2)

    p1 = binom.cdf(x, p=p, n=n)
    p2 = dist.cdf(x, p, n)

    np.allclose(p1, p2) 
开发者ID:NICTA,项目名称:revrand,代码行数:21,代码来源:test_likelihoods.py

示例7: test_poisson

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def test_poisson():

    # Test we can at match a Binomial distribution from scipy

    mu = 2
    dist = lk.Poisson()

    x = np.random.randint(low=0, high=5, size=(10,))

    p1 = poisson.logpmf(x, mu)
    p2 = dist.loglike(x, mu)

    np.allclose(p1, p2)

    p1 = poisson.cdf(x, mu)
    p2 = dist.cdf(x, mu)

    np.allclose(p1, p2) 
开发者ID:NICTA,项目名称:revrand,代码行数:20,代码来源:test_likelihoods.py

示例8: _p_val

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def _p_val(self):
        r"""
        Returns the p-value.

        Returns
        -------
        p : float
            The computed p value.

        Notes
        -----
        When sample sizes are large enough (:math:`n > 20`), the distribution of :math:`U` is normally
        distributed.

        """
        p = 1 - norm.cdf(self.z_value)

        return p * 2 
开发者ID:aschleg,项目名称:hypothetical,代码行数:20,代码来源:nonparametric.py

示例9: __call__

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def __call__(self, df_resid, nobs, resid):
        h = (df_resid)/nobs*(self.d**2 + (1-self.d**2)*\
                    Gaussian.cdf(self.d)-.5 - self.d/(np.sqrt(2*np.pi))*\
                    np.exp(-.5*self.d**2))
        s = mad(resid)
        subset = lambda x: np.less(np.fabs(resid/x),self.d)
        chi = lambda s: subset(s)*(resid/s)**2/2+(1-subset(s))*(self.d**2/2)
        scalehist = [np.inf,s]
        niter = 1
        while (np.abs(scalehist[niter-1] - scalehist[niter])>self.tol \
                and niter < self.maxiter):
            nscale = np.sqrt(1/(nobs*h)*np.sum(chi(scalehist[-1]))*\
                    scalehist[-1]**2)
            scalehist.append(nscale)
            niter += 1
            #if niter == self.maxiter:
            #    raise ValueError("Huber's scale failed to converge")
        return scalehist[-1] 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:20,代码来源:scale.py

示例10: testSecurityNormInvValueHolder

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def testSecurityNormInvValueHolder(self):
        mm1 = SecurityNormInvValueHolder('open')
        mm2 = SecurityNormInvValueHolder('open', fullAcc=True)

        for i in range(len(self.aapl['close'])):
            data = dict(aapl=dict(open=norm.cdf(self.aapl['open'][i])),
                        ibm=dict(open=norm.cdf(self.ibm['open'][i])))
            mm1.push(data)
            mm2.push(data)

            value1 = mm1.value
            value2 = mm2.value
            for name in value1.index():
                expected = norm.ppf(data[name]['open'])
                calculated = value1[name]
                self.assertAlmostEqual(expected, calculated, 6, 'at index {0}\n'
                                                                'expected:   {1:.12f}\n'
                                                                'calculat: {2:.12f}'
                                       .format(i, expected, calculated))

                calculated = value2[name]
                self.assertAlmostEqual(expected, calculated, 12, 'at index {0}\n'
                                                                 'expected:   {1:.12f}\n'
                                                                 'calculat: {2:.12f}'
                                       .format(i, expected, calculated)) 
开发者ID:alpha-miner,项目名称:Finance-Python,代码行数:27,代码来源:testStatelessTechnicalAnalysers.py

示例11: testSecurityCeilValueHolder

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def testSecurityCeilValueHolder(self):
        mm1 = SecurityCeilValueHolder('open')

        for i in range(len(self.aapl['close'])):
            data = dict(aapl=dict(open=norm.cdf(self.aapl['open'][i])),
                        ibm=dict(open=norm.cdf(self.ibm['open'][i])))
            mm1.push(data)

            value1 = mm1.value
            for name in value1.index():
                expected = math.ceil(data[name]['open'])
                calculated = value1[name]
                self.assertAlmostEqual(expected, calculated, 6, 'at index {0}\n'
                                                                'expected:   {1:.12f}\n'
                                                                'calculat: {2:.12f}'
                                       .format(i, expected, calculated)) 
开发者ID:alpha-miner,项目名称:Finance-Python,代码行数:18,代码来源:testStatelessTechnicalAnalysers.py

示例12: testSecurityFloorValueHolder

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def testSecurityFloorValueHolder(self):
        mm1 = SecurityFloorValueHolder('open')

        for i in range(len(self.aapl['close'])):
            data = dict(aapl=dict(open=norm.cdf(self.aapl['open'][i])),
                        ibm=dict(open=norm.cdf(self.ibm['open'][i])))
            mm1.push(data)

            value1 = mm1.value
            for name in value1.index():
                expected = math.floor(data[name]['open'])
                calculated = value1[name]
                self.assertAlmostEqual(expected, calculated, 6, 'at index {0}\n'
                                                                'expected:   {1:.12f}\n'
                                                                'calculat: {2:.12f}'
                                       .format(i, expected, calculated)) 
开发者ID:alpha-miner,项目名称:Finance-Python,代码行数:18,代码来源:testStatelessTechnicalAnalysers.py

示例13: testSecurityRoundValueHolder

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def testSecurityRoundValueHolder(self):
        mm1 = SecurityRoundValueHolder('open')

        for i in range(len(self.aapl['close'])):
            data = dict(aapl=dict(open=norm.cdf(self.aapl['open'][i])),
                        ibm=dict(open=norm.cdf(self.ibm['open'][i])))
            mm1.push(data)

            value1 = mm1.value
            for name in value1.index():
                expected = round(data[name]['open'])
                calculated = value1[name]
                self.assertAlmostEqual(expected, calculated, 6, 'at index {0}\n'
                                                                'expected:   {1:.12f}\n'
                                                                'calculat: {2:.12f}'
                                       .format(i, expected, calculated)) 
开发者ID:alpha-miner,项目名称:Finance-Python,代码行数:18,代码来源:testStatelessTechnicalAnalysers.py

示例14: test_broadcasting

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def test_broadcasting(self):
        np.random.seed(1234)
        n = 4

        # Construct a random covariance matrix.
        data = np.random.randn(n, n)
        cov = np.dot(data, data.T)
        mean = np.random.randn(n)

        # Construct an ndarray which can be interpreted as
        # a 2x3 array whose elements are random data vectors.
        X = np.random.randn(2, 3, n)

        # Check that multiple data points can be evaluated at once.
        desired_pdf = multivariate_normal.pdf(X, mean, cov)
        desired_cdf = multivariate_normal.cdf(X, mean, cov)
        for i in range(2):
            for j in range(3):
                actual = multivariate_normal.pdf(X[i, j], mean, cov)
                assert_allclose(actual, desired_pdf[i,j])
                # Repeat for cdf
                actual = multivariate_normal.cdf(X[i, j], mean, cov)
                assert_allclose(actual, desired_cdf[i,j], rtol=1e-3) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:25,代码来源:test_multivariate.py

示例15: test_haar

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import cdf [as 别名]
def test_haar(self):
        # Test that the eigenvalues, which lie on the unit circle in
        # the complex plane, are uncorrelated.

        # Generate samples
        dim = 5
        samples = 1000  # Not too many, or the test takes too long
        np.random.seed(514)  # Note that the test is sensitive to seed too
        xs = unitary_group.rvs(dim, size=samples)

        # The angles "x" of the eigenvalues should be uniformly distributed
        # Overall this seems to be a necessary but weak test of the distribution.
        eigs = np.vstack(scipy.linalg.eigvals(x) for x in xs)
        x = np.arctan2(eigs.imag, eigs.real)
        res = kstest(x.ravel(), uniform(-np.pi, 2*np.pi).cdf)
        assert_(res.pvalue > 0.05) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:18,代码来源:test_multivariate.py


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