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


Python norm.pdf方法代码示例

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


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

示例1: lnprob

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def lnprob(self, theta):

        lp = 0

        # Covariance amplitude
        lp += self.ln_prior.lnprob(theta[0])

        # Lengthscales
        lp += self.tophat.lnprob(theta[1:self.n_ls + 1])

        # Prior for the Bayesian regression kernel
        pos = (self.n_ls + 1)
        end = (self.n_ls + self.n_lr + 1)
        lp += -np.sum((theta[pos:end]) ** 2 / 10.)

        # alpha
        lp += norm.pdf(theta[end], loc=-7, scale=1)
        # beta
        lp += norm.pdf(theta[end + 1], loc=0.5, scale=1)

        # Noise
        lp += self.horseshoe.lnprob(theta[-1])

        return lp 
开发者ID:automl,项目名称:RoBO,代码行数:26,代码来源:env_priors.py

示例2: encode_extreme_points

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def encode_extreme_points(mask, use_gaussian):
  nz = mask.nonzero()
  assert nz[0].size > 0, "mask cannot be empty"
  ymin_idx = nz[0].argmin()
  ymax_idx = nz[0].argmax()
  xmin_idx = nz[1].argmin()
  xmax_idx = nz[1].argmax()
  ymin = (nz[0][ymin_idx], nz[1][ymin_idx])
  ymax = (nz[0][ymax_idx], nz[1][ymax_idx])
  xmin = (nz[0][xmin_idx], nz[1][xmin_idx])
  xmax = (nz[0][xmax_idx], nz[1][xmax_idx])
  pts = (ymin, ymax, xmin, xmax)
  distance_transform_extreme_pts = get_distance_transform(pts, mask)
  distance_transform_extreme_pts[distance_transform_extreme_pts > 20] = 20
  if use_gaussian:
    distance_transform_extreme_pts = norm.pdf(distance_transform_extreme_pts, loc=0, scale=10) * 25
  else:
    distance_transform_extreme_pts /= 20.0
  return distance_transform_extreme_pts.astype(np.float32) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:21,代码来源:DistanceTransform.py

示例3: test_marginalization

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def test_marginalization(self):
        # Integrating out one of the variables of a 2D Gaussian should
        # yield a 1D Gaussian
        mean = np.array([2.5, 3.5])
        cov = np.array([[.5, 0.2], [0.2, .6]])
        n = 2 ** 8 + 1  # Number of samples
        delta = 6 / (n - 1)  # Grid spacing

        v = np.linspace(0, 6, n)
        xv, yv = np.meshgrid(v, v)
        pos = np.empty((n, n, 2))
        pos[:, :, 0] = xv
        pos[:, :, 1] = yv
        pdf = multivariate_normal.pdf(pos, mean, cov)

        # Marginalize over x and y axis
        margin_x = romb(pdf, delta, axis=0)
        margin_y = romb(pdf, delta, axis=1)

        # Compare with standard normal distribution
        gauss_x = norm.pdf(v, loc=mean[0], scale=cov[0, 0] ** 0.5)
        gauss_y = norm.pdf(v, loc=mean[1], scale=cov[1, 1] ** 0.5)
        assert_allclose(margin_x, gauss_x, rtol=1e-2, atol=1e-2)
        assert_allclose(margin_y, gauss_y, rtol=1e-2, atol=1e-2) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:26,代码来源:test_multivariate.py

示例4: test_frozen_matrix_normal

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def test_frozen_matrix_normal(self):
        for i in range(1,5):
            for j in range(1,5):
                M = 0.3 * np.ones((i,j))
                U = 0.5 * np.identity(i) + 0.5 * np.ones((i,i))
                V = 0.7 * np.identity(j) + 0.3 * np.ones((j,j))

                frozen = matrix_normal(mean=M, rowcov=U, colcov=V)

                rvs1 = frozen.rvs(random_state=1234)
                rvs2 = matrix_normal.rvs(mean=M, rowcov=U, colcov=V,
                                         random_state=1234)
                assert_equal(rvs1, rvs2)

                X = frozen.rvs(random_state=1234)

                pdf1 = frozen.pdf(X)
                pdf2 = matrix_normal.pdf(X, mean=M, rowcov=U, colcov=V)
                assert_equal(pdf1, pdf2)

                logpdf1 = frozen.logpdf(X)
                logpdf2 = matrix_normal.logpdf(X, mean=M, rowcov=U, colcov=V)
                assert_equal(logpdf1, logpdf2) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:25,代码来源:test_multivariate.py

示例5: test_frozen_dirichlet

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def test_frozen_dirichlet(self):
        np.random.seed(2846)

        n = np.random.randint(1, 32)
        alpha = np.random.uniform(10e-10, 100, n)

        d = dirichlet(alpha)

        assert_equal(d.var(), dirichlet.var(alpha))
        assert_equal(d.mean(), dirichlet.mean(alpha))
        assert_equal(d.entropy(), dirichlet.entropy(alpha))
        num_tests = 10
        for i in range(num_tests):
            x = np.random.uniform(10e-10, 100, n)
            x /= np.sum(x)
            assert_equal(d.pdf(x[:-1]), dirichlet.pdf(x[:-1], alpha))
            assert_equal(d.logpdf(x[:-1]), dirichlet.logpdf(x[:-1], alpha)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:19,代码来源:test_multivariate.py

示例6: sensorModel

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def sensorModel(particles, numParticles, boxX, boxY):
    totalW = 0
    for i in range(numParticles):
        x = particles[i].x
        y = particles[i].y
        dx = abs(boxX - x)
        dy = abs(boxY - y)
        dist = math.sqrt(dx**2 + dy**2)

        if dist == 0:
            dist = 0.1

        bias = 1/dist
        particles[i].weight = norm.pdf(bias)
        totalW += particles[i].weight

    for i in range(numParticles):
        particles[i].weight = particles[i].weight/totalW

    return particles 
开发者ID:sahibdhanjal,项目名称:Mask-RCNN-Pedestrian-Detection,代码行数:22,代码来源:particleFilter.py

示例7: EI

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def EI(y_best, predictions, uncertainty, objective='max'):
    """Return expected improvement acq. function.

    Parameters
    ----------
    y_best : float
        Condition
    predictions : list
        Predicted means.
    uncertainty : list
        Uncertainties associated with the predictions.
    """
    if objective == 'max':
        z = (predictions - y_best) / (uncertainty)
        return (predictions - y_best) * norm.cdf(z) + \
            uncertainty * norm.pdf(
            z)

    if objective == 'min':
        z = (-predictions + y_best) / (uncertainty)
        return -((predictions - y_best) * norm.cdf(z) -
                 uncertainty * norm.pdf(z)) 
开发者ID:SUNCAT-Center,项目名称:CatLearn,代码行数:24,代码来源:acquisition_functions.py

示例8: ExpectedImprovement

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def ExpectedImprovement(self, tau, mean, std):
        """
        Expected Improvement acquisition function.

        Parameters
        ----------
        tau: float
            Best observed function evaluation.
        mean: float
            Point mean of the posterior process.
        std: float
            Point std of the posterior process.

        Returns
        -------
        float
            Expected improvement.
        """
        z = (mean - tau - self.eps) / (std + self.eps)
        return (mean - tau) * norm.cdf(z) + std * norm.pdf(z)[0] 
开发者ID:josejimenezluna,项目名称:pyGPGO,代码行数:22,代码来源:acquisition.py

示例9: tExpectedImprovement

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def tExpectedImprovement(self, tau, mean, std, nu=3.0):
        """
        Expected Improvement acquisition function. Only to be used with `tStudentProcess` surrogate.

        Parameters
        ----------
        tau: float
            Best observed function evaluation.
        mean: float
            Point mean of the posterior process.
        std: float
            Point std of the posterior process.

        Returns
        -------
        float
            Expected improvement.
        """
        gamma = (mean - tau - self.eps) / (std + self.eps)
        return gamma * std * t.cdf(gamma, df=nu) + std * (1 + (gamma ** 2 - 1)/(nu - 1)) * t.pdf(gamma, df=nu) 
开发者ID:josejimenezluna,项目名称:pyGPGO,代码行数:22,代码来源:acquisition.py

示例10: piece_linear

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def piece_linear(self, hyper, M, prob_R):
        '''
        model: straight line
        '''
        c, slope, sigma, trans = self.split_hyper_linear(hyper)
        R = np.zeros_like(M)
        for i in range(4):
            ind = self.indicate(M, trans, i)
            mu = c[i] + M[ind]*slope[i]
            R[ind] = norm.ppf(prob_R[ind], mu, sigma[i])
        return R

#     # Unused functions
#     def classification(self, logm, trans ):
#         '''
#         classify as four worlds
#         '''
#         count = np.zeros(4)
#         sample_size = len(logm)
#         for iclass in range(4):
#             for isample in range(sample_size):
#                 ind = self.indicate( logm[isample], trans[isample], iclass)
#                 count[iclass] = count[iclass] + ind
#         prob = count / np.sum(count) * 100.
#         print 'Terran %(T).1f %%, Neptunian %(N).1f %%, Jovian %(J).1f %%, Star %(S).1f %%' \
#                 % {'T': prob[0], 'N': prob[1], 'J': prob[2], 'S': prob[3]}
#         return None
# 
#     def ProbRGivenM(self, radii, M, hyper):
#         '''
#         p(radii|M)
#         '''
#         c, slope, sigma, trans = self.split_hyper_linear(hyper)
#         prob = np.zeros_like(M)
#         for i in range(4):
#             ind = self.indicate(M, trans, i)
#             mu = c[i] + M[ind]*slope[i]
#             sig = sigma[i]
#             prob[ind] = norm.pdf(radii, mu, sig)
#         prob = prob/np.sum(prob)
#         return prob 
开发者ID:dsavransky,项目名称:EXOSIMS,代码行数:43,代码来源:Forecaster.py

示例11: _gen_beta_data

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def _gen_beta_data(Z, rng, separation=.9, distargs=None):
    n_rows = len(Z)

    K = np.max(Z)+1
    alphas = np.linspace(.5 - .5*separation*.85, .5 + .5*separation*.85, K)
    Tc = np.zeros(n_rows)

    for r in xrange(n_rows):
        cluster = Z[r]
        alpha = alphas[cluster]
        beta = (1.-alpha) * 20.* (norm.pdf(alpha, .5, .25))
        alpha *= 20. * norm.pdf(alpha, .5, .25)
        Tc[r] = rng.beta(alpha, beta)

    return Tc 
开发者ID:probcomp,项目名称:cgpm,代码行数:17,代码来源:test.py

示例12: compute

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def compute(self, X_test, derivative=False):
        """
        Computes the PI value and its derivatives.

        Parameters
        ----------
        X_test: np.ndarray(1, D), The input point where the acquisition_functions function
            should be evaluate. The dimensionality of X is (N, D), with N as
            the number of points to evaluate at and D is the number of
            dimensions of one X.

        derivative: Boolean
            If is set to true also the derivative of the acquisition_functions
            function at X is returned

        Returns
        -------
        np.ndarray(1,1)
            Probability of Improvement of X_test
        np.ndarray(1,D)
            Derivative of Probability of Improvement at X_test
            (only if derivative=True)
        """

        m, v = self.model.predict(X_test)
        _, inc_val = self.model.get_incumbent()

        s = np.sqrt(v)
        z = (inc_val - m - self.par) / s
        f = norm.cdf(z)

        if derivative:
            dmdx, ds2dx = self.model.predictive_gradients(X_test)
            dmdx = dmdx[0]
            ds2dx = ds2dx[0][:, None]
            dsdx = ds2dx / (2 * s)
            df = ((-norm.pdf(z) / s) * (dmdx + dsdx * z)).T
            return f, df
        else:
            return f 
开发者ID:automl,项目名称:RoBO,代码行数:42,代码来源:pi.py

示例13: __init__

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def __init__(self, c=1.5, tol=1.0e-08, maxiter=30, norm=None):
        self.c = c
        self.maxiter = maxiter
        self.tol = tol
        self.norm = norm
        tmp = 2 * Gaussian.cdf(c) - 1
        self.gamma = tmp + c**2 * (1 - tmp) - 2 * c * Gaussian.pdf(c) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:9,代码来源:scale.py

示例14: hall_sheather

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def hall_sheather(n, q, alpha=.05):
    z = norm.ppf(q)
    num = 1.5 * norm.pdf(z)**2.
    den = 2. * z**2. + 1.
    h = n**(-1. / 3) * norm.ppf(1. - alpha / 2.)**(2./3) * (num / den)**(1./3)
    return h 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:quantile_regression.py

示例15: bofinger

# 需要导入模块: from scipy.stats import norm [as 别名]
# 或者: from scipy.stats.norm import pdf [as 别名]
def bofinger(n, q):
    num = 9. / 2 * norm.pdf(2 * norm.ppf(q))**4
    den = (2 * norm.ppf(q)**2 + 1)**2
    h = n**(-1. / 5) * (num / den)**(1. / 5)
    return h 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:quantile_regression.py


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