Python scipy.special.ndtri() Examples

The following are 30 code examples of scipy.special.ndtri(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module scipy.special , or try the search function .
Example #1
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _ppf(self, q, c):
        tmp = c*sc.ndtri(q)
        return 0.25 * (tmp + np.sqrt(tmp**2 + 4))**2 
Example #2
Source File: nested_sampling.py    From allesfitter with MIT License 5 votes vote down vote up
def ns_prior_transform(utheta):
#    global config.BASEMENT
    theta = np.zeros_like(utheta)*np.nan
    for i in range(len(theta)):
        if config.BASEMENT.bounds[i][0]=='uniform':
            theta[i] = utheta[i]*(config.BASEMENT.bounds[i][2]-config.BASEMENT.bounds[i][1]) + config.BASEMENT.bounds[i][1]
        elif config.BASEMENT.bounds[i][0]=='normal':
            theta[i] = config.BASEMENT.bounds[i][1] + config.BASEMENT.bounds[i][2]*ndtri(utheta[i])
        elif config.BASEMENT.bounds[i][0]=='trunc_normal':
            theta[i] = my_truncnorm_isf(utheta[i],config.BASEMENT.bounds[i][1],config.BASEMENT.bounds[i][2],config.BASEMENT.bounds[i][3],config.BASEMENT.bounds[i][4]) 
        else:
            raise ValueError('Bounds have to be "uniform", "normal" and "trunc_normal". Input from "params.csv" was "'+config.BASEMENT.bounds[i][0]+'".')
    return theta 
Example #3
Source File: log_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, x, a):
        return numpy.e**(a*special.ndtri(x)) 
Example #4
Source File: power_log_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, c, s):
        return numpy.exp(-s*special.ndtri(pow(1.-q, 1./c))) 
Example #5
Source File: alpha.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, a):
        return 1.0/(a-special.ndtri(q*special.ndtr(a))) 
Example #6
Source File: mv_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, C, Ci, loc):
        return (numpy.dot(C, special.ndtri(q)).T+loc.T).T 
Example #7
Source File: trunc_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, a, b, mu, sigma):
        fa = special.ndtr((a-mu)/sigma)
        fb = special.ndtr((b-mu)/sigma)
        return special.ndtri(q*(fb-fa) + fa)*sigma + mu 
Example #8
Source File: power_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, c):
        return -special.ndtri(pow(1-q, 1./c)) 
Example #9
Source File: levy.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q):
        val = special.ndtri(1-q/2.0)
        return 1.0/(val*val) 
Example #10
Source File: fatigue_life.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, c):
        tmp = c*special.ndtri(q)
        return 0.25*(tmp + numpy.sqrt(tmp**2 + 4))**2 
Example #11
Source File: nataf.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, C, Ci):
        out = special.ndtr(numpy.dot(C, special.ndtri(q)))
        return out 
Example #12
Source File: nataf.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, C, Ci):
        out = special.ndtr(numpy.dot(Ci, special.ndtri(x)))
        return out 
Example #13
Source File: test_crps.py    From properscoring with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        np.random.seed(1983)
        shape = (2, 3)
        self.mu = np.random.normal(size=shape)
        self.sig = np.square(np.random.normal(size=shape))
        self.obs = np.random.normal(loc=self.mu, scale=self.sig, size=shape)

        n = 1000
        q = np.linspace(0. + 0.5 / n, 1. - 0.5 / n, n)
        # convert to the corresponding normal deviates
        normppf = special.ndtri
        z = normppf(q)

        forecasts = z.reshape(-1, 1, 1) * self.sig + self.mu
        self.expected = crps_ensemble(self.obs, forecasts, axis=0) 
Example #14
Source File: transforms.py    From NiMARE with MIT License 5 votes vote down vote up
def p_to_z(p, tail='two'):
    """Convert p-values to (unsigned) z-values.

    Parameters
    ----------
    p : array_like
        P-values
    tail : {'one', 'two'}, optional
        Whether p-values come from one-tailed or two-tailed test. Default is
        'two'.

    Returns
    -------
    z : array_like
        Z-statistics (unsigned)
    """
    eps = np.spacing(1)
    p = np.array(p)
    p[p < eps] = eps
    if tail == 'two':
        z = ndtri(1 - (p / 2))
        z = np.array(z)
    elif tail == 'one':
        z = ndtri(1 - p)
        z = np.array(z)
        z[z < 0] = 0
    else:
        raise ValueError('Argument "tail" must be one of ["one", "two"]')

    if z.shape == ():
        z = z[()]
    return z 
Example #15
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _ppf(self, q):
        # Equivalent to 1.0/(norm.isf(q/2)**2) or 0.5/(erfcinv(q)**2)
        val = -sc.ndtri(q/2)
        return 1.0 / (val * val) 
Example #16
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _ppf(self, q):
        return sc.ndtri((1+q)/2.0) 
Example #17
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _norm_ppf(q):
    return sc.ndtri(q) 
Example #18
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _ppf(self, q, a):
        return 1.0/np.asarray(a-sc.ndtri(q*_norm_cdf(a))) 
Example #19
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _norm_ppf(q):
    return sc.ndtri(q) 
Example #20
Source File: _continuous_distns.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _ppf(self, q):
        # Equivalent to 1.0/(norm.isf(q/2)**2) or 0.5/(erfcinv(q)**2)
        val = -sc.ndtri(q/2)
        return 1.0 / (val * val) 
Example #21
Source File: _continuous_distns.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _ppf(self, q):
        return sc.ndtri((1+q)/2.0) 
Example #22
Source File: _continuous_distns.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _ppf(self, q, c):
        tmp = c*sc.ndtri(q)
        return 0.25 * (tmp + np.sqrt(tmp**2 + 4))**2 
Example #23
Source File: _continuous_distns.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _ppf(self, q, a):
        return 1.0/np.asarray(a-sc.ndtri(q*_norm_cdf(a))) 
Example #24
Source File: _continuous_distns.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _norm_ppf(q):
    return sc.ndtri(q) 
Example #25
Source File: ndtri.py    From chainer with MIT License 5 votes vote down vote up
def ndtri(x):
    """Elementwise inverse function of ndtr.

    .. note::
       Forward computation in CPU can not 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 Ndtri().apply((x,))[0] 
Example #26
Source File: ndtri.py    From chainer with MIT License 5 votes vote down vote up
def forward_cpu(self, x):
        if not available_cpu:
            raise ImportError('SciPy is not available. Forward computation'
                              ' of ndtri in CPU can not be done.' +
                              str(_import_error))
        self.retain_outputs((0,))
        return utils.force_array(special.ndtri(x[0]), dtype=x[0].dtype), 
Example #27
Source File: ndtri.py    From chainer with MIT License 5 votes vote down vote up
def label(self):
        return 'ndtri' 
Example #28
Source File: test_ndtri.py    From chainer with MIT License 5 votes vote down vote up
def _ndtri_cpu(x, dtype):
    from scipy import special
    return numpy.vectorize(special.ndtri, otypes=[dtype])(x) 
Example #29
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q):
        # Equivalent to 1.0/(norm.isf(q/2)**2) or 0.5/(erfcinv(q)**2)
        val = -sc.ndtri(q/2)
        return 1.0 / (val * val) 
Example #30
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q):
        return sc.ndtri((1+q)/2.0)