Python scipy.special.ndtr() Examples

The following are 30 code examples of scipy.special.ndtr(). 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: special_math_test.py    From deep_image_model with Apache License 2.0 6 votes vote down vote up
def _test_grid_no_log(self, dtype, grid_spec, error_spec):
    with self.test_session():
      grid = _make_grid(dtype, grid_spec)
      actual = sm.ndtr(grid).eval()

      # Basic tests.
      self.assertTrue(np.isfinite(actual).all())
      # On the grid, 0 < cdf(x) < 1.  The grid cannot contain everything due
      # to numerical limitations of cdf.
      self.assertTrue((actual > 0).all())
      self.assertTrue((actual < 1).all())
      _check_strictly_increasing(actual)

      # Versus scipy.
      expected = special.ndtr(grid)
      # Scipy prematurely goes to zero at some places that we don't.  So don't
      # include these in the comparison.
      self.assertAllClose(expected.astype(np.float64)[expected < 0],
                          actual.astype(np.float64)[expected < 0],
                          rtol=error_spec.rtol, atol=error_spec.atol) 
Example #2
Source File: trunc_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, a, b, mu, sigma):
        fa = special.ndtr((a-mu)/sigma)
        fb = special.ndtr((b-mu)/sigma)
        x = special.ndtr((x-mu)/sigma)
        return (x - fa) / (fb-fa) 
Example #3
Source File: edgeworth.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _norm_sf(x):
    return special.ndtr(-x) 
Example #4
Source File: kde.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def integrate_box_1d(self, low, high):
        """
        Computes the integral of a 1D pdf between two bounds.

        Parameters
        ----------
        low : scalar
            Lower bound of integration.
        high : scalar
            Upper bound of integration.

        Returns
        -------
        value : scalar
            The result of the integral.

        Raises
        ------
        ValueError
            If the KDE is over more than one dimension.

        """
        if self.d != 1:
            raise ValueError("integrate_box_1d() only handles 1D pdfs")

        stdev = ravel(sqrt(self.covariance))[0]

        normalized_low = ravel((low - self.dataset) / stdev)
        normalized_high = ravel((high - self.dataset) / stdev)

        value = np.mean(special.ndtr(normalized_high) -
                        special.ndtr(normalized_low))
        return value 
Example #5
Source File: _continuous_distns.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _norm_cdf(x):
    return sc.ndtr(x) 
Example #6
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 #7
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 #8
Source File: fatigue_life.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, c):
        return special.ndtr(1.0/c*(numpy.sqrt(x)-1.0/numpy.sqrt(x))) 
Example #9
Source File: levy.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x):
        return 2*(1-special.ndtr(1/numpy.sqrt(x))) 
Example #10
Source File: power_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _pdf(self, x, c):
        norm = (2*numpy.pi)**-.5*numpy.exp(-x**2/2.)
        return c*norm*special.ndtr(-x)**(c-1.) 
Example #11
Source File: mv_log_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, loc, C, Ci, scale):
        y = numpy.log(numpy.abs(x) + 1.*(x<=0))
        out = special.ndtr(numpy.dot(Ci, (y.T-loc.T).T))
        return numpy.where(x <= 0, 0., out) 
Example #12
Source File: trunc_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _pdf(self, x, a, b, mu, sigma):
        fa = special.ndtr((a-mu)/sigma)
        fb = special.ndtr((b-mu)/sigma)
        x = (x-mu)/sigma
        norm = (2*numpy.pi)**(-.5)*numpy.e**(-x**2/2.)
        return norm/(fb-fa) 
Example #13
Source File: edgeworth.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _norm_cdf(x):
    return special.ndtr(x) 
Example #14
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 #15
Source File: mv_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, C, Ci, loc):
        return special.ndtr(numpy.dot(Ci, (x.T-loc.T).T)) 
Example #16
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 #17
Source File: alpha.py    From chaospy with MIT License 5 votes vote down vote up
def _pdf(self, x, a):
        return (1.0/(x**2)/special.ndtr(a)*
            numpy.e**(.5*(a-1.0/x)**2)/numpy.sqrt(2*numpy.pi)) 
Example #18
Source File: wald.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, mu):
        trm1 = 1./mu - x
        trm2 = 1./mu + x
        isqx = numpy.tile(numpy.inf, x.shape)
        indices = x > 0
        isqx[indices] = 1./numpy.sqrt(x[indices])
        out = 1.-special.ndtr(isqx*trm1)
        out -= numpy.exp(2.0/mu)*special.ndtr(-isqx*trm2)
        return out 
Example #19
Source File: folded_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, c):
        return special.ndtr(x-c) + special.ndtr(x+c) - 1.0 
Example #20
Source File: power_log_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _pdf(self, x, c, s):
        norm = (2*numpy.pi)**-.5*numpy.exp(-(numpy.log(x)/s)**2/2.)
        return c/(x*s)*norm*pow(special.ndtr(-numpy.log(x)/s), c*1.-1.) 
Example #21
Source File: log_normal.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x, a):
        return special.ndtr(numpy.log(x+(1-x)*(x<=0))/a)*(x>0) 
Example #22
Source File: normal.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x):
        return special.ndtr(x) 
Example #23
Source File: test_stress.py    From chaospy with MIT License 5 votes vote down vote up
def _cdf(self, x):
        return special.ndtr(x) 
Example #24
Source File: kde.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def integrate_box_1d(self, low, high):
        """
        Computes the integral of a 1D pdf between two bounds.

        Parameters
        ----------
        low : scalar
            Lower bound of integration.
        high : scalar
            Upper bound of integration.

        Returns
        -------
        value : scalar
            The result of the integral.

        Raises
        ------
        ValueError
            If the KDE is over more than one dimension.

        """
        if self.d != 1:
            raise ValueError("integrate_box_1d() only handles 1D pdfs")

        stdev = ravel(sqrt(self.covariance))[0]

        normalized_low = ravel((low - self.dataset) / stdev)
        normalized_high = ravel((high - self.dataset) / stdev)

        value = np.mean(special.ndtr(normalized_high) -
                        special.ndtr(normalized_low))
        return value 
Example #25
Source File: LogOddsRatioUninformativeDirichletPrior.py    From scattertext with Apache License 2.0 5 votes vote down vote up
def get_p_values_from_counts(self, y_i, y_j):
		return ndtr(self.get_zeta_i_j_given_separate_counts(y_i, y_j)) 
Example #26
Source File: LogOddsRatioInformativeDirichletPiror.py    From scattertext with Apache License 2.0 5 votes vote down vote up
def z_to_p_val(z_scores):
	# return norm.sf(-z_scores) - 0.5 + 0.5
	return ndtr(z_scores) 
Example #27
Source File: LogOddsRatioSmoothed.py    From scattertext with Apache License 2.0 5 votes vote down vote up
def z_to_p_val(z_scores):
	# return norm.sf(-z_scores) - 0.5 + 0.5
	return ndtr(z_scores) 
Example #28
Source File: kde.py    From lambda-packs with MIT License 5 votes vote down vote up
def integrate_box_1d(self, low, high):
        """
        Computes the integral of a 1D pdf between two bounds.

        Parameters
        ----------
        low : scalar
            Lower bound of integration.
        high : scalar
            Upper bound of integration.

        Returns
        -------
        value : scalar
            The result of the integral.

        Raises
        ------
        ValueError
            If the KDE is over more than one dimension.

        """
        if self.d != 1:
            raise ValueError("integrate_box_1d() only handles 1D pdfs")

        stdev = ravel(sqrt(self.covariance))[0]

        normalized_low = ravel((low - self.dataset) / stdev)
        normalized_high = ravel((high - self.dataset) / stdev)

        value = np.mean(special.ndtr(normalized_high) -
                        special.ndtr(normalized_low))
        return value 
Example #29
Source File: _continuous_distns.py    From lambda-packs with MIT License 5 votes vote down vote up
def _norm_cdf(x):
    return sc.ndtr(x) 
Example #30
Source File: edgeworth.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def _norm_cdf(x):
    return special.ndtr(x)