PDF of Weibull distribution

@param x Value
@param k Shape parameter
@param lambda Scale parameter
@param theta Shift offset parameter
@return PDF at position x.
439042
public static double logpdf(double x, double k, double lambda, double theta) {
    if(x <= theta || x == Double.POSITIVE_INFINITY) {
      return Double.NEGATIVE_INFINITY;
    }
    double xl = (x - theta) / lambda;
    return FastMath.log(k / lambda) + (k - 1) * FastMath.log(xl) - FastMath.pow(xl, k);
  }
167920
public static double pdf(double x, double mu, double sigma, double lambda) {
    final double dx = x - mu;
    final double lss = lambda * sigma * sigma;
    final double erfc = NormalDistribution.erfc((lss - dx) / (sigma * MathUtil.SQRT2));
    return erfc > 0. ? .5 * lambda * FastMath.exp(lambda * (lss * .5 - dx)) * erfc : (x == x) ? 0. : Double.NaN;
  }
1348769
def pdf(self, X):
                      
        return invwishart.pdf(X, df=self.v, scale=self.Psi)
607121
def gauss_pdf(x, mu, sigma):
    """"""
    return 1 / np.sqrt(2 * np.pi) / sigma * np.exp(-(x - mu) ** 2 / 2. / sigma ** 2)
186552
public static double quantile(double p, double k, double theta, double shift) {
    return FastMath.log(GammaDistribution.quantile(p, k, 1)) / theta + shift;
  }
114246
public static double pdf(double x, double dof) {
    if(x <= 0) {
      return 0.0;
    }
    if(dof <= 0) {
      return Double.NaN;
    }
    final double k = dof * .5;
    return (Math.abs(k - 1.0) < Double.MIN_NORMAL) ? FastMath.exp(-x * 2.0) * 2.0 : //
        FastMath.exp((k - 1.0) * FastMath.log(x * 2.0) - x * 2.0 - logGamma(k)) * 2.0;
  }
855525
function partial( sigma ) {
	var s2 = pow( sigma, 2 );
	/**
	* FUNCTION: pdf( x )
	*	Evaluates the probability density function (PDF) for a Rayleigh distribution.
	*
	* @private
	* @param {Number} x - input value
	* @returns {Number} evaluated PDF
	*/
	return function pdf( x ) {
		if ( x < 0 ) {
			return 0;
		}
		return (1/s2) * x * exp( -pow( x, 2 ) / ( 2 * s2 ) );
	};
}
892568
public static double pdf(double val, double loc, double scale, double shape) {
    if(!(val < Double.POSITIVE_INFINITY && val > Double.NEGATIVE_INFINITY)) {
      return val == val ? 0. : Double.NaN;
    }
    val = (val - loc) / scale;
    double e = FastMath.exp(-val);
    double f = 1. + e;
    return e < Double.POSITIVE_INFINITY ? shape * e / (scale * FastMath.pow(f, shape + 1.)) : 0.;
  }
1255834
def pdf(x, mu, std):
    """"""
    return (1.0 / (std * sqrt(2 * pi))) * np.exp(-(x - mu) ** 2 / (2 * std ** 2))
687722
public static double logNormalDistribution(double sigma, double x) {
        return Math.log(1.0 / (sqrt(2.0 * PI) * sigma)) + (-0.5 * pow(x / sigma, 2));
    }
665477
public static double pdf(double x, double mu, double shape) {
    if(!(x > 0) || x == Double.POSITIVE_INFINITY) {
      return x == x ? 0 : Double.NaN;
    }
    final double v = (x - mu) / mu;
    double t1 = FastMath.sqrt(shape / (MathUtil.TWOPI * x * x * x));
    return t1 > 0 ? t1 * FastMath.exp(-shape * v * v * .5 / x) : 0;
  }
948824
def _expval(self, f, nopdf):
        
        def ff(theta, nopdf=nopdf):
            tan_theta = numpy.tan(theta)
            x = self.scale * tan_theta
            jac = self.scale * (tan_theta ** 2 + 1.)
            if nopdf:
                pdf = jac * self.pdf.pjac[None, :]
            else:
                pdf = jac * numpy.exp(-(x ** 2) / 2.) / numpy.sqrt(2 * numpy.pi)
            dp = self.pdf.x2dpflat(x)
            parg = None
            ans = None
            fparg_is_dict = False
            # iterate through the batch
            for i, (dpi, pdfi) in enumerate(zip(dp, pdf)):
                p = self.pdf.meanflat + dpi
                if parg is None:
                    # first time only
                    if self.pdf.shape is None:
                        parg = _gvar.BufferDict(self.pdf.g, buf=p)
                    else:
                        parg = p.reshape(self.pdf.shape)
                else:
                    if parg.shape is None:
                        parg.buf = p
                    else:
                        parg.flat[:] = p
                fparg = 1. if f is None else f(parg)
                if ans is None:
                    # first time only
                    if hasattr(fparg, 'keys'):
                        fparg_is_dict = True
                        if not isinstance(fparg, _gvar.BufferDict):
                            fparg = _gvar.BufferDict(fparg)
                        ans = _gvar.BufferDict()
                        for k in fparg:
                            ans[k] = numpy.empty(
                                (len(pdf),) + fparg.slice_shape(k)[1], float
                                )
                    else:
                        if numpy.shape(fparg) == ():
                            ans = numpy.empty(len(pdf), float)
                        else:
                            ans = numpy.empty(
                                (len(pdf),) + numpy.shape(fparg), float
                                )
                if fparg_is_dict:
                    prod_pdfi = numpy.prod(pdfi)
                    for k in ans:
                        ans[k][i] = fparg[k]
                        ans[k][i] *= prod_pdfi
                else:
                    if not isinstance(fparg, numpy.ndarray):
                        fparg = numpy.asarray(fparg)
                    ans[i] = fparg * numpy.prod(pdfi)
            return ans
        return ff
357605
def probability_density(self, X):
        """"""
        self.check_fit()

        U, V = self.split_matrix(X)

        if self.theta == 1:
            return np.multiply(U, V)

        else:
            a = np.power(np.multiply(U, V), -1)
            tmp = np.power(-np.log(U), self.theta) + np.power(-np.log(V), self.theta)
            b = np.power(tmp, -2 + 2.0 / self.theta)
            c = np.power(np.multiply(np.log(U), np.log(V)), self.theta - 1)
            d = 1 + (self.theta - 1) * np.power(tmp, -1.0 / self.theta)
            return self.cumulative_distribution(X) * a * b * c * d
477909
public static double pdf(double x, double k, double theta) {
    if(x < 0) {
      return 0.;
    }
    if(x == 0) {
      return (k == 1.) ? theta : 0;
    }
    if(k == 1.) {
      return FastMath.exp(-x * theta) * theta;
    }
    final double xt = x * theta;
    return (xt == Double.POSITIVE_INFINITY) ? 0. : //
        FastMath.exp((k - 1.0) * FastMath.log(xt) - xt - logGamma(k)) * theta;
  }
853739
public static double quantile(double p, double k, double theta, double shift) {
    return FastMath.exp(GammaDistribution.quantile(p, k, theta)) + shift;
  }
491921
public static final Vector3D randVertex2d() {
        float theta = random((float)(Math.PI*2.0));
        return new Vector3D(Math.cos(theta),Math.sin(theta));
    }
763014
def Kdiag(self, X):
        """"""
        ret = np.empty(X.shape[0])
        ret[:] = self.variance
        return ret