Exemple #1
0
    def cdf(self, x, *args, **kwds):
        """
        Cumulative distribution function at x of the given RV.

        Parameters
        ----------
        x : array-like
            quantiles
        arg1, arg2, arg3,... : array-like
            The shape parameter(s) for the distribution (see docstring of the
            instance object for more information)
        loc : array-like, optional
            location parameter (default=0)
        scale : array-like, optional
            scale parameter (default=1)

        Returns
        -------
        cdf : array-like
            Cumulative distribution function evaluated at x

        """
        (loc, scale) = map(kwds.get, ['loc', 'scale'])
        (args, loc, scale) = self._fix_loc_scale(args, loc, scale)
        (x, loc, scale, shape) = map(arr, (x, loc, scale, args[0]))
        x = (x - loc) * 1.0 / scale
        # 
        isgamma = (shape > 0) & (scale != 0)
        isnorm = (shape == 0) & (scale > 0)
        ispe3 = (isnorm | isgamma)
        indomain = (x > self.a) & (x < self.b)
        toolarge = (x >= self.b)
        valid = ispe3 & indomain
        output = np.zeros(np.shape(valid), 'd')
        np.place(output, (1 - ispe3) * (indomain == indomain), self.badvalue)
        np.place(output, toolarge, 1.0)
        if any(valid):  #call only if at least 1 entry
            (x, shape) = argsreduce(valid, *((x,) + (shape,)))
            vals = self._cdf(x, shape)
            np.place(output, (valid & isgamma),
                     np.where(scale > 0, vals, 1. - vals))
            np.place(output, (valid & isnorm), dist._norm_cdf(x))
        if output.ndim == 0:
            return output[()]
        return output
Exemple #2
0
 def _cdf(self, x):
     y = (x - self._mu) / self._sigma
     return (distributions._norm_cdf(y) +
             self._herm_cdf(y) * distributions._norm_pdf(y))