예제 #1
0
    def pdf(self, x, *args, **kwds):
        """
        Probability density 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
        -------
        pdf : array-like
            Probability density 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
        scale = np.abs(scale)
        # 
        isgamma = (shape > 0) & (scale != 0)
        isnorm = (shape == 0) & (scale > 0)
        ispe3 = (isgamma | isnorm)
        indom = (x > self.a) & (x < self.b)
        valid = ispe3 & indom
        #
        output = np.zeros(np.shape(valid), 'd')
        np.putmask(output, (1 - ispe3) * np.array(indom, bool), self.badvalue)
        (x, shape, scale) = argsreduce(valid, *((x, shape, scale,)))
        np.place(output, (valid & isgamma), self._pdf(x, shape) / scale)
        np.place(output, (valid & isnorm), dist._norm_pdf(x) / scale)
        if output.ndim == 0:
            return output[()]
        return output
예제 #2
0
 def norm_pdf(x):
     return np.where(np.isinf(x), 0, _norm_pdf(x))
예제 #3
0
 def _sf(self, x):
     y = (x - self._mu) / self._sigma
     return (distributions._norm_sf(y) -
             self._herm_cdf(y) * distributions._norm_pdf(y))
예제 #4
0
 def _pdf(self, x):
     y = (x - self._mu) / self._sigma
     return self._herm_pdf(y) * distributions._norm_pdf(y) / self._sigma