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


Python math.erfc方法代码示例

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


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

示例1: compute_kullback_leibler_check_statistic

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def compute_kullback_leibler_check_statistic(n=100, prngstate=None):
    """Compute the lowest of the survival function and the CDF of the exact KL
    divergence KL(N(mu1,s1)||N(mu2,s2)) w.r.t. the sample distribution of the
    KL divergence drawn by computing log(P(x|N(mu1,s1)))-log(P(x|N(mu2,s2)))
    over a sample x~N(mu1,s1). If we are computing the KL divergence
    accurately, the exact value should fall squarely in the sample, and the
    tail probabilities should be relatively large.

    """
    if prngstate is None:
        raise TypeError('Must explicitly specify numpy.random.RandomState')
    mu1 = mu2 = 0
    s1 = 1
    s2 = 2
    exact = gaussian_kl_divergence(mu1, s1, mu2, s2)
    sample = prngstate.normal(mu1, s1, n)
    lpdf1 = gaussian_log_pdf(mu1, s1)
    lpdf2 = gaussian_log_pdf(mu2, s2)
    estimate, std = kl.kullback_leibler(sample, lpdf1, lpdf2)
    # This computes the minimum of the left and right tail probabilities of the
    # exact KL divergence vs a gaussian fit to the sample estimate. There is a
    # distinct negative skew to the samples used to compute `estimate`, so this
    # statistic is not uniform. Nonetheless, we do not expect it to get too
    # small.
    return erfc(abs(exact - estimate) / std) / 2 
开发者ID:probcomp,项目名称:bayeslite,代码行数:27,代码来源:test_kl.py

示例2: ndtr

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def ndtr(a):
    """
    Returns the area under the Gaussian probability density function,
    integrated from minus infinity to x.

    See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.ndtr.html#scipy.special.ndtr

    """
    sqrth = math.sqrt(2) / 2
    x = float(a) * sqrth
    z = abs(x)
    if z < sqrth:
        y = 0.5 + 0.5 * math.erf(x)
    else:
        y = 0.5 * math.erfc(z)
        if x > 0:
            y = 1 - y
    return y 
开发者ID:mozilla,项目名称:python_moztelemetry,代码行数:20,代码来源:stats.py

示例3: runs_test

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def runs_test(bits):
    n = len(bits)
    zeroes,ones = count_ones_zeroes(bits)

    prop = float(ones)/float(n)
    print("  prop ",prop)

    tau = 2.0/math.sqrt(n)
    print("  tau ",tau)

    if abs(prop-0.5) > tau:
        return (False,0.0,None)

    vobs = 1.0
    for i in range(n-1):
        if bits[i] != bits[i+1]:
            vobs += 1.0

    print("  vobs ",vobs)
      
    p = math.erfc(abs(vobs - (2.0*n*prop*(1.0-prop)))/(2.0*math.sqrt(2.0*n)*prop*(1-prop) ))
    success = (p >= 0.01)
    return (success,p,None) 
开发者ID:dj-on-github,项目名称:sp800_22_tests,代码行数:25,代码来源:sp800_22_runs_test.py

示例4: get_quantiles

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def get_quantiles(acquisition_par, fmin, m, s):
    '''
    Quantiles of the Gaussian distribution useful to determine the acquisition function values
    :param acquisition_par: parameter of the acquisition function
    :param fmin: current minimum.
    :param m: vector of means.
    :param s: vector of standard deviations.
    '''
    if isinstance(s, np.ndarray):
        s[s<1e-10] = 1e-10
    elif s< 1e-10:
        s = 1e-10
    u = (fmin - m - acquisition_par)/s

    phi = np.exp(-0.5 * u**2) / np.sqrt(2*np.pi)
    # vectorized version of erfc to not depend on scipy
    Phi = 0.5 * erfc(-u / np.sqrt(2))
    return (phi, Phi, u) 
开发者ID:awslabs,项目名称:autogluon,代码行数:20,代码来源:density.py

示例5: __call__

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def __call__(self, state, scope, pos, paramTypes, a):
        try:
            return math.erfc(a)
        except:
            raise PFARuntimeException("domain error", self.errcodeBase + 0, self.name, pos) 
开发者ID:modelop,项目名称:hadrian,代码行数:7,代码来源:spec.py

示例6: test_erf_erfc

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def test_erf_erfc(self):
        tolerance = 15
        for x in itertools.count(0.0, 0.001):
            if x > 5.0:
                break
            self.assertAlmostEqual(math.erf(x), -math.erf(-x), places=tolerance)
            self.assertAlmostEqual(math.erfc(x), 2.0 - math.erfc(-x), places=tolerance)

            self.assertAlmostEqual(1.0 - math.erf(x), math.erfc(x), places=tolerance)
            self.assertAlmostEqual(1.0 - math.erf(-x), math.erfc(-x), places=tolerance)
            self.assertAlmostEqual(1.0 - math.erfc(x), math.erf(x), places=tolerance)
            self.assertAlmostEqual(1.0 - math.erfc(-x), math.erf(-x), places=tolerance) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_math.py

示例7: __call__

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def __call__(self, val):
        return __inline_fora(
            """fun(@unnamed_args:(val), *args) {
                   PyFloat(math.erfc(val.@m))
                   }"""
            )(val) 
开发者ID:ufora,项目名称:ufora,代码行数:8,代码来源:pure_math.py

示例8: test_pure_python_math_module

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def test_pure_python_math_module(self):
        vals = [1, -.5, 1.5, 0, 0.0, -2, -2.2, .2]

        # not being tested: math.asinh, math.atanh, math.lgamma, math.erfc, math.acos
        def f():
            functions = [
                math.sqrt, math.cos, math.sin, math.tan, math.asin, math.atan,
                math.acosh, math.cosh, math.sinh, math.tanh, math.ceil,
                math.erf, math.exp, math.expm1, math.factorial, math.floor,
                math.log, math.log10, math.log1p
            ]
            tr = []
            for idx1 in range(len(vals)):
                v1 = vals[idx1]
                for funIdx in range(len(functions)):
                    function = functions[funIdx]
                    try:
                        tr = tr + [function(v1)]
                    except ValueError as ex:
                        pass

            return tr

        r1 = self.evaluateWithExecutor(f)
        r2 = f()
        self.assertGreater(len(r1), 100)
        self.assertTrue(numpy.allclose(r1, r2, 1e-6)) 
开发者ID:ufora,项目名称:ufora,代码行数:29,代码来源:MathTestCases.py

示例9: _erfc_cpu

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def _erfc_cpu(x, dtype):
    return numpy.vectorize(math.erfc, otypes=[dtype])(x) 
开发者ID:chainer,项目名称:chainer,代码行数:4,代码来源:test_erfc.py

示例10: _ndtr_cpu

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def _ndtr_cpu(x, dtype):
    erfc = numpy.vectorize(
        lambda x: 0.5 * math.erfc(-x / 2 ** 0.5))
    return utils.force_array(erfc(x), dtype=dtype) 
开发者ID:chainer,项目名称:chainer,代码行数:6,代码来源:test_ndtr.py

示例11: _slow_ndtr_cpu

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def _slow_ndtr_cpu(x):
    return 0.5 * math.erfc(-x / 2 ** 0.5) 
开发者ID:chainer,项目名称:chainer,代码行数:4,代码来源:ndtr.py

示例12: label

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def label(self):
        return 'erfc' 
开发者ID:chainer,项目名称:chainer,代码行数:4,代码来源:erfc.py

示例13: forward_cpu

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def forward_cpu(self, x):
        global _erfc_cpu
        if _erfc_cpu is None:
            try:
                from scipy import special
                _erfc_cpu = special.erfc
            except ImportError:
                warnings.warn(
                    'SciPy is not available. Forward computation of erfc in'
                    ' CPU can be slow without SciPy.',
                    chainer.warnings.PerformanceWarning)
                _erfc_cpu = numpy.vectorize(math.erfc)
        self.retain_inputs((0,))
        return utils.force_array(_erfc_cpu(x[0]), dtype=x[0].dtype), 
开发者ID:chainer,项目名称:chainer,代码行数:16,代码来源:erfc.py

示例14: erfc

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def erfc(x):
    """Elementwise complementary error function.

    .. note::
       Forward computation in CPU can be slow if
       `SciPy <https://www.scipy.org/>`_ is not available.

    Args:
        x (:class:`~chainer.Variable` or :ref:`ndarray`): Input variable.

    Returns:
        ~chainer.Variable: Output variable.
    """
    return Erfc().apply((x,))[0] 
开发者ID:chainer,项目名称:chainer,代码行数:16,代码来源:erfc.py

示例15: normcdf

# 需要导入模块: import math [as 别名]
# 或者: from math import erfc [as 别名]
def normcdf(n):
    return 0.5 * math.erfc(-n * math.sqrt(0.5)) 
开发者ID:dj-on-github,项目名称:sp800_22_tests,代码行数:4,代码来源:sp800_22_cumulative_sums_test.py


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