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


Python special.erfinv方法代码示例

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


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

示例1: std_iqr

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def std_iqr(x):
    """Robust estimation of the standard deviation, based on the inter-quartile
    (IQR) distance of x.
    This computes the IQR of x, and applies the Gaussian distribution
    correction, making it a consistent estimator of the standard-deviation
    (when the sample looks Gaussian with outliers).

    Parameters
    ----------
    x : `np.ndarray`
        Input vector

    Returns
    -------
    output : `float`
        A robust estimation of the standard deviation
    """
    from scipy.stats import iqr
    from scipy.special import erfinv

    correction = 2 ** 0.5 * erfinv(0.5)
    return correction * iqr(x) 
开发者ID:X-DataInitiative,项目名称:tick,代码行数:24,代码来源:robust.py

示例2: _using_cdf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def _using_cdf(self, x, exp):

        # Get the value of the cumulative probability function, instead of the survival function (1 - cdf),
        # because for extreme values sf(x) = 1 - cdf(x) = 1 due to numerical precision problems

        cdf = scipy.stats.poisson.cdf(x, exp)

        # print(cdf)

        out = np.zeros_like(x)

        idx = cdf >= 2 * self._epsilon

        # We can do a direct computation, because the numerical precision is sufficient
        # for this computation, as -sf = cdf - 1 is a representable number

        out[idx] = erfinv(2 * cdf[idx] - 1) * sqrt(2)

        # We use a lookup table with interpolation because the numerical precision would not
        # be sufficient to make the computation

        out[~idx] = -1 * self._interpolator(np.log10(cdf[~idx]))

        return out 
开发者ID:threeML,项目名称:threeML,代码行数:26,代码来源:stats_tools.py

示例3: date_uncertainty_due_to_rate

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def date_uncertainty_due_to_rate(self, node, interval=(0.05, 0.095)):
        """use previously calculated variation of the rate to estimate
        the uncertainty in a particular numdate due to rate variation.

        Parameters
        ----------
        node : PhyloTree.Clade
            node for which the confidence interval is to be calculated
        interval : tuple, optional
            Array of length two, or tuple, defining the bounds of the confidence interval

        """
        if hasattr(node, "numdate_rate_variation"):
            from scipy.special import erfinv
            nsig = [np.sqrt(2.0)*erfinv(-1.0 + 2.0*x) if x*(1.0-x) else 0
                    for x in interval]
            l,c,u = [x[1] for x in node.numdate_rate_variation]
            return np.array([c + x*np.abs(y-c) for x,y in zip(nsig, (l,u))])

        else:
            return None 
开发者ID:neherlab,项目名称:treetime,代码行数:23,代码来源:clock_tree.py

示例4: test_erfinv

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def test_erfinv() -> None:
    try:
        from scipy.special import erfinv as scipy_erfinv
    except:
        pytest.skip("scipy not installed skipping test for erf")

    x = np.linspace(-1.0 + 1.0e-4, 1 - 1.0e-4, 11)
    y_scipy = scipy_erfinv(x)

    # Test mx.nd
    y_mxnet = util.erfinv(mx.nd, mx.nd.array(x)).asnumpy()
    assert np.allclose(y_mxnet, y_scipy, rtol=1e-3)

    # Test mx.sym
    X = mx.symbol.Variable("x")
    func = util.erfinv(mx.sym, X)
    func_exec = func.bind(ctx=mx.cpu(), args={"x": mx.nd.array(x)})
    func_exec.forward()
    y_mxnet_sym = func_exec.outputs[0].asnumpy()
    assert np.allclose(y_mxnet_sym, y_scipy, rtol=1e-3)

    # Text np
    y_np = util.erfinv(np, x)
    assert np.allclose(y_np, y_scipy, rtol=1e-3) 
开发者ID:awslabs,项目名称:gluon-ts,代码行数:26,代码来源:test_util.py

示例5: _rescale

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def _rescale(self, samp, **kwargs):
        try:
            mode = kwargs['mode']
        except KeyError:
            mode = None

        if mode is None:
            if self.nmodes == 1:
                mode = 0
            else:
                mode = np.argwhere(self.cumweights - np.random.rand() > 0)[0][0]

        samp = erfinv(2. * samp - 1) * 2. ** 0.5

        # rotate and scale to the multivariate normal shape
        samp = self.mus[mode] + self.sigmas[mode] * np.einsum('ij,kj->ik',
                                                              samp * self.sqeigvalues[mode],
                                                              self.eigvectors[mode])
        return samp 
开发者ID:lscsoft,项目名称:bilby,代码行数:21,代码来源:joint.py

示例6: _function

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def _function(self,
                 variable=None,
                 context=None,
                 params=None,
                 ):

        try:
            from scipy.special import erfinv
        except:
            raise FunctionError("The UniformToNormalDist function requires the SciPy package.")

        mean = self._get_current_function_param(DIST_MEAN, context)
        standard_deviation = self._get_current_function_param(STANDARD_DEVIATION, context)
        random_state = self._get_current_function_param('random_state', context)

        sample = random_state.rand(1)[0]
        result = ((np.sqrt(2) * erfinv(2 * sample - 1)) * standard_deviation) + mean

        return self.convert_output_type(result) 
开发者ID:PrincetonUniversity,项目名称:PsyNeuLink,代码行数:21,代码来源:distributionfunctions.py

示例7: test_erfinv

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def test_erfinv(self):
        i = special.erfinv(0)
        assert_equal(i,0) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:test_basic.py

示例8: xi_hat

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def xi_hat(self, xi_bar_hat):
		"""
		A priori SNR estimate.

		Argument/s:
			xi_bar_hat - mapped a priori SNR estimate.

		Returns:
			A priori SNR estimate.
		"""
		xi_db_hat = np.add(np.multiply(np.multiply(self.sigma, np.sqrt(2.0)),
			spsp.erfinv(np.subtract(np.multiply(2.0, xi_bar_hat), 1))), self.mu)
		return np.power(10.0, np.divide(xi_db_hat, 10.0)) 
开发者ID:anicolson,项目名称:DeepXi,代码行数:15,代码来源:sig.py

示例9: _erfinv_cpu

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def _erfinv_cpu(x, dtype):
    from scipy import special
    return numpy.vectorize(special.erfinv, otypes=[dtype])(x) 
开发者ID:chainer,项目名称:chainer,代码行数:5,代码来源:test_erfinv.py

示例10: label

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

示例11: forward_cpu

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def forward_cpu(self, x):
        if not available_cpu:
            raise ImportError('SciPy is not available. Forward computation'
                              ' of erfinv in CPU cannot be done. ' +
                              str(_import_error))
        self.retain_outputs((0,))
        return utils.force_array(special.erfinv(x[0]), dtype=x[0].dtype), 
开发者ID:chainer,项目名称:chainer,代码行数:9,代码来源:erfinv.py

示例12: forward_gpu

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def forward_gpu(self, x):
        self.retain_outputs((0,))
        return cuda.elementwise(
            'T x', 'T y',
            'y = erfinv(x)',
            'elementwise_erfinv',
        )(x[0]), 
开发者ID:chainer,项目名称:chainer,代码行数:9,代码来源:erfinv.py

示例13: erfinv

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def erfinv(x):
    """Elementwise inverse function of error function.

    .. note::
       Forward computation in CPU cannot be done 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 ErfInv().apply((x,))[0] 
开发者ID:chainer,项目名称:chainer,代码行数:16,代码来源:erfinv.py

示例14: _zinnharvey

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def _zinnharvey(field, conn="high", mean=None, var=None):
    """
    Zinn and Harvey transformation to connect low or high values.

    Parameters
    ----------
    field : :class:`numpy.ndarray`
        Spatial Random Field with normal distributed values.
        As returned by SRF.
    conn : :class:`str`, optional
        Desired connectivity. Either "low" or "high".
        Default: "high"
    mean : :class:`float` or :any:`None`, optional
        Mean of the given field. If None is given, the mean will be calculated.
        Default: :any:`None`
    var : :class:`float` or :any:`None`, optional
        Variance of the given field.
        If None is given, the mean will be calculated.
        Default: :any:`None`

    Returns
    -------
        :class:`numpy.ndarray`
            Transformed field.
    """
    if mean is None:
        mean = np.mean(field)
    if var is None:
        var = np.var(field)
    field = np.abs((field - mean) / np.sqrt(var))
    field = 2 * erf(field / np.sqrt(2)) - 1
    field = np.sqrt(2) * erfinv(field)
    if conn == "high":
        field = -field
    return field * np.sqrt(var) + mean 
开发者ID:GeoStat-Framework,项目名称:GSTools,代码行数:37,代码来源:field.py

示例15: spectral_rad_ppf

# 需要导入模块: from scipy import special [as 别名]
# 或者: from scipy.special import erfinv [as 别名]
def spectral_rad_ppf(self, u):
        """Radial spectral ppf.

        Notes
        -----
        Not defined for 3D.
        """
        u = np.array(u, dtype=np.double)
        if self.dim == 1:
            return sps.erfinv(u) * np.sqrt(np.pi) / self.len_scale
        if self.dim == 2:
            return np.sqrt(np.pi) / self.len_scale * np.sqrt(-np.log(1.0 - u))
        return None 
开发者ID:GeoStat-Framework,项目名称:GSTools,代码行数:15,代码来源:models.py


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