Python scipy.special.gammaincinv() Examples

The following are 30 code examples of scipy.special.gammaincinv(). 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):
        return np.sqrt(2*sc.gammaincinv(1.5, q)) 
Example #2
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q, df):
        return np.sqrt(2*sc.gammaincinv(.5*df, q)) 
Example #3
Source File: test_basic.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def test_gammainccinv(self):
        gccinv = special.gammainccinv(.5,.5)
        gcinv = special.gammaincinv(.5,.5)
        assert_almost_equal(gccinv,gcinv,8) 
Example #4
Source File: test_basic.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def test_975(self):
        # Regression test for ticket #975 -- switch point in algorithm
        # check that things work OK at the point, immediately next floats
        # around it, and a bit further away
        pts = [0.25,
               np.nextafter(0.25, 0), 0.25 - 1e-12,
               np.nextafter(0.25, 1), 0.25 + 1e-12]
        for xp in pts:
            y = special.gammaincinv(.4, xp)
            x = special.gammainc(0.4, y)
            assert_allclose(x, xp, rtol=1e-12) 
Example #5
Source File: test_gammainc.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def test_gammainc_roundtrip():
    a = np.logspace(-5, 10, 100)
    x = np.logspace(-5, 10, 100)

    y = sc.gammaincinv(a, sc.gammainc(a, x))
    assert_allclose(x, y, rtol=1e-10) 
Example #6
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, df):
        return np.sqrt(2*sc.gammaincinv(.5*df, q)) 
Example #7
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 sc.gammaincinv(a, q) 
Example #8
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, c):
        val1 = sc.gammaincinv(a, q)
        val2 = sc.gammainccinv(a, q)
        return np.where(c > 0, val1, val2)**(1.0/c) 
Example #9
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _isf(self, q, a, c):
        val1 = sc.gammaincinv(a, q)
        val2 = sc.gammainccinv(a, q)
        return np.where(c > 0, val2, val1)**(1.0/c) 
Example #10
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _isf(self, q, a):
        return 1.0 / sc.gammaincinv(a, q) 
Example #11
Source File: _continuous_distns.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def _ppf(self, x, beta):
        return sc.gammaincinv(1.0/beta, x)**(1.0/beta) 
Example #12
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, nu):
        return np.sqrt(1.0/nu*sc.gammaincinv(nu, q)) 
Example #13
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, skew):
        ans, q, _, mask, invmask, beta, alpha, zeta = (
            self._preprocess(q, skew))
        ans[mask] = _norm_ppf(q[mask])
        ans[invmask] = sc.gammaincinv(alpha, q[invmask])/beta + zeta
        return ans 
Example #14
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, x, beta):
        return sc.gammaincinv(1.0/beta, x)**(1.0/beta) 
Example #15
Source File: gamma.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, a):
        return special.gammaincinv(a, q) 
Example #16
Source File: log_gamma.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, c):
        return numpy.log(special.gammaincinv(c,q)) 
Example #17
Source File: nakagami.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, nu):
        return numpy.sqrt(1.0/nu*special.gammaincinv(nu, q)) 
Example #18
Source File: generalized_gamma.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, a, c):
        val1 = special.gammaincinv(a, q)
        val2 = special.gammaincinv(a, 1.0-q)
        ic = 1.0/c
        cond = c+0*val1
        return numpy.where(cond > 0, val1**ic, val2**ic) 
Example #19
Source File: chi.py    From chaospy with MIT License 5 votes vote down vote up
def _ppf(self, q, df):
        return numpy.sqrt(2*special.gammaincinv(df*0.5, q)) 
Example #20
Source File: regression.py    From convoys with MIT License 5 votes vote down vote up
def rvs(self, x, n_curves=1, n_samples=1, T=None):
        ''' Samples values from this distribution

        T is optional and means we already observed non-conversion until T
        '''
        assert self._mcmc  # Need to be fit with MCMC
        if T is None:
            T = numpy.zeros((n_curves, n_samples))
        else:
            assert T.shape == (n_curves, n_samples)
        B = numpy.zeros((n_curves, n_samples), dtype=numpy.bool)
        C = numpy.zeros((n_curves, n_samples))
        params = self.params['samples']
        for i, j in enumerate(numpy.random.randint(len(params['k']),
                                                   size=n_curves)):
            k = params['k'][j]
            p = params['p'][j]
            lambd = exp(dot(x, params['alpha'][j]) + params['a'][j])
            c = expit(dot(x, params['beta'][j]) + params['b'][j])
            z = numpy.random.uniform(size=(n_samples,))
            cdf_now = c * gammainc(
                k,
                numpy.multiply.outer(T[i], lambd)**p)  # why is this outer?
            adjusted_z = cdf_now + (1 - cdf_now) * z
            B[i] = (adjusted_z < c)
            y = adjusted_z / c
            w = gammaincinv(k, y)
            # x = (t * lambd)**p
            C[i] = w**(1./p) / lambd
            C[i][~B[i]] = 0

        return B, C 
Example #21
Source File: test_basic.py    From Computable with MIT License 5 votes vote down vote up
def test_gammaincinv(self):
        y = special.gammaincinv(.4,.4)
        x = special.gammainc(.4,y)
        assert_almost_equal(x,0.4,1)
        y = special.gammainc(10, 0.05)
        x = special.gammaincinv(10, 2.5715803516000736e-20)
        assert_almost_equal(0.05, x, decimal=10)
        assert_almost_equal(y, 2.5715803516000736e-20, decimal=10)
        x = special.gammaincinv(50, 8.20754777388471303050299243573393e-18)
        assert_almost_equal(11.0, x, decimal=10) 
Example #22
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q, a):
        return sc.gammaincinv(a, q) 
Example #23
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q, a, c):
        val1 = sc.gammaincinv(a, q)
        val2 = sc.gammainccinv(a, q)
        return np.where(c > 0, val1, val2)**(1.0/c) 
Example #24
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _isf(self, q, a, c):
        val1 = sc.gammaincinv(a, q)
        val2 = sc.gammainccinv(a, q)
        return np.where(c > 0, val2, val1)**(1.0/c) 
Example #25
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _isf(self, q, a):
        return 1.0 / sc.gammaincinv(a, q) 
Example #26
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q):
        return np.sqrt(2*sc.gammaincinv(1.5, q)) 
Example #27
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q, nu):
        return np.sqrt(1.0/nu*sc.gammaincinv(nu, q)) 
Example #28
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, q, skew):
        ans, q, _, mask, invmask, beta, alpha, zeta = (
            self._preprocess(q, skew))
        ans[mask] = _norm_ppf(q[mask])
        ans[invmask] = sc.gammaincinv(alpha, q[invmask])/beta + zeta
        return ans 
Example #29
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _ppf(self, x, beta):
        return sc.gammaincinv(1.0/beta, x)**(1.0/beta) 
Example #30
Source File: test_basic.py    From Computable with MIT License 5 votes vote down vote up
def test_gammainccinv(self):
        gccinv = special.gammainccinv(.5,.5)
        gcinv = special.gammaincinv(.5,.5)
        assert_almost_equal(gccinv,gcinv,8)