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


Python math.erf方法代码示例

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


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

示例1: ndtr

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [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

示例2: expimp

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def expimp(self, x):
        '''
        Returns the expected improvement at the design vector X in the model
        :param x: A real world coordinates design vector
        :return EI: The expected improvement value at the point x in the model
        '''
        S = self.predicterr_normalized(x)
        y_min = np.min(self.y)
        if S <= 0.:
            EI = 0.
        elif S > 0.:
            EI_one = ((y_min - self.predict_normalized(x)) * (0.5 + 0.5*m.erf((
                      1./np.sqrt(2.))*((y_min - self.predict_normalized(x)) /
                                       S))))
            EI_two = ((S * (1. / np.sqrt(2. * np.pi))) * (np.exp(-(1./2.) *
                      ((y_min - self.predict_normalized(x))**2. / S**2.))))
            EI = EI_one + EI_two
        return EI 
开发者ID:capaulson,项目名称:pyKriging,代码行数:20,代码来源:regressionkrige.py

示例3: erf_local

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def erf_local(x):
    # save the sign of x
    sign = 1 if x >= 0 else -1
    x = abs(x)

    # constants
    a1 =  0.254829592
    a2 = -0.284496736
    a3 =  1.421413741
    a4 = -1.453152027
    a5 =  1.061405429
    p  =  0.3275911

    # A&S formula 7.1.26
    t = 1.0/(1.0 + p*x)
    y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*math.exp(-x*x)
    return sign*y # erf(-x) = -erf(x) 
开发者ID:spectralpython,项目名称:spectral,代码行数:19,代码来源:resampling.py

示例4: integral_gaussian

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def integral_gaussian(a, b, mu, sigma):
    """
    Computes the integral of a gaussian centered
    in mu with a given sigma
    :param a:
    :param b:
    :param mu:
    :param sigma:
    :return:
    """

    # Integral from -\infty to a
    val_floor = 0.5 * (1 + math.erf((a - mu) / (sigma * math.sqrt(2.0))))

    # Integral from -\infty to b
    val_ceil = 0.5 * (1 + math.erf((b - mu) / (sigma * sqrt(2.0))))

    return val_ceil - val_floor 
开发者ID:MaterialsDiscovery,项目名称:PyChemia,代码行数:20,代码来源:mathematics.py

示例5: erfinv

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def erfinv(y):
    # courtesy of
    # https://github.com/antelopeusersgroup/antelope_contrib/blob/master/lib/location/libgenloc/erfinv.c#L15
    a = [0.886226899, -1.645349621, 0.914624893, -0.140543331]
    b = [-2.118377725, 1.442710462, -0.329097515, 0.012229801]
    c = [-1.970840454, -1.624906493, 3.429567803, 1.641345311]
    d = [3.543889200, 1.637067800]
    if y > 1:
        return None
    if y == 1:
        return math.copysign(1, y) * float("inf")
    if y <= 0.7:
        z = y * y
        num = (((a[3] * z + a[2]) * z + a[1]) * z + a[0])
        dem = ((((b[3] * z + b[2]) * z + b[1]) * z + b[0]) * z + 1.0)
        x = y * num / dem
    else:
        z = math.sqrt(-math.log((1.0 - abs(y)) / 2.0))
        num = ((c[3] * z + c[2]) * z + c[1]) * z + c[0]
        dem = (d[1] * z + d[0]) * z + 1.0
        x = (math.copysign(1.0, y)) * num / dem
    for _ in [1, 2]:
        x = x - (erf(x) - y) / ((2 / math.sqrt(trig.c_pi)) * math.exp(-x * x))
    return x 
开发者ID:TuringApp,项目名称:Turing,代码行数:26,代码来源:stats.py

示例6: integral_default_gaussian

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def integral_default_gaussian(y, x):
    """Calculate the value of the integral from x to y of the erf function

    Parameters
    ----------
    y : float
        upper limit
    x : float
        lower limit

    Returns
    -------
    float
        Calculated value of integral

    """
    return 0.5 * (math.erf(x) - math.erf(y)) 
开发者ID:SunPower,项目名称:pvfactors,代码行数:19,代码来源:utils.py

示例7: sum_of_erf

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def sum_of_erf(mu, sigma, N=1000):
    """
    Compute the sum of erf term

    :param mu: The Gaussian mean
    :param sigma: The Gaussian sigma
    :param N: The number of iterations in the sum
    """
    from math import sqrt, erf

    sum1 = 0
    sum2 = N * erf((N + 1 - mu) / (sqrt(2) * sigma))
    sum3 = N * erf((-N - mu) / (sqrt(2) * sigma))
    for i in range(-N, N):
        sum1 += erf((i + 1 - mu) / (sqrt(2) * sigma))
    return -0.5 * (sum1 + sum2 + sum3) 
开发者ID:dials,项目名称:dials,代码行数:18,代码来源:generate_bias_lookup_table.py

示例8: __call__

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def __call__(self, state, scope, pos, paramTypes, x):
        return unwrapForNorm(x, lambda y: (math.erf(y/math.sqrt(2.)) + 1.)/2.) 
开发者ID:modelop,项目名称:hadrian,代码行数:4,代码来源:link.py

示例9: CDF

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def CDF(self, x):
        if (self.sigma == 0.0) and (x < self.mu):
            return 0.0
        elif (self.sigma == 0.0) and (x >= self.mu):
            return 1.0
        else:
            return 0.5 * (1.0 + math.erf((x - self.mu)/(self.sigma * math.sqrt(2.0)))) 
开发者ID:modelop,项目名称:hadrian,代码行数:9,代码来源:dist.py

示例10: __call__

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

示例11: Erf

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def Erf(self):
    return unary(self, 'erf(' + str(self._name_no_id()) + ')', (lambda x: math.erf(self.value()))) 
开发者ID:timkpaine,项目名称:tributary,代码行数:4,代码来源:ops.py

示例12: __array_ufunc__

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
    if ufunc == np.add:
        if isinstance(inputs[0], Node):
            return inputs[0].__add__(inputs[1])
        else:
            return inputs[1].__add__(inputs[0])
    elif ufunc == np.subtract:
        if isinstance(inputs[0], Node):
            return inputs[0].__sub__(inputs[1])
        else:
            return inputs[1].__sub__(inputs[0])
    elif ufunc == np.multiply:
        if isinstance(inputs[0], Node):
            return inputs[0].__mul__(inputs[1])
        else:
            return inputs[1].__mul__(inputs[0])
    elif ufunc == np.divide:
        if isinstance(inputs[0], Node):
            return inputs[0].__truediv__(inputs[1])
        else:
            return inputs[1].__truediv__(inputs[0])
    elif ufunc == np.sin:
        return inputs[0].sin()
    elif ufunc == np.cos:
        return inputs[0].cos()
    elif ufunc == np.tan:
        return inputs[0].tan()
    elif ufunc == np.arcsin:
        return inputs[0].asin()
    elif ufunc == np.arccos:
        return inputs[0].acos()
    elif ufunc == np.arctan:
        return inputs[0].atan()
    elif ufunc == np.exp:
        return inputs[0].exp()
    elif ufunc == sp.special.erf:
        return inputs[0].erf()
    raise NotImplementedError('Not Implemented!') 
开发者ID:timkpaine,项目名称:tributary,代码行数:40,代码来源:ops.py

示例13: test_Erf

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def test_Erf(self):
        t = tl.Node(value=2)
        out = tl.Erf(t)
        assert out() == math.erf(2) 
开发者ID:timkpaine,项目名称:tributary,代码行数:6,代码来源:test_ops_lazy.py

示例14: test_Erf

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [as 别名]
def test_Erf(self):
        t = ts.Timer(foo, count=2)
        out = ts.Erf(t)
        assert ts.run(out) == [math.erf(1), math.erf(2)] 
开发者ID:timkpaine,项目名称:tributary,代码行数:6,代码来源:test_ops_streaming.py

示例15: test_erf_erfc

# 需要导入模块: import math [as 别名]
# 或者: from math import erf [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


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