Cumulative probability density function (CDF) of a Wald distribution.

@param x value to evaluate CDF at
@param mu Mean value
@param shape Shape parameter
@return The CDF of the given Wald distribution at x.
324823
public static double cdf(double x, double mu, double shape) {
    if(!(x > 0.)) {
      return x == x ? 0. : Double.NaN;
    }
    // TODO: accelerate by caching exp(2 * shape / mu).
    final double v0 = x / mu;
    final double v1 = FastMath.sqrt(shape / x);
    if(v1 == 0.) {
      return v0 > 0. ? 1 : 0.;
    }
    double c1 = NormalDistribution.standardNormalCDF(v1 * (v0 - 1.));
    double c2 = NormalDistribution.standardNormalCDF(-v1 * (v0 + 1.));
    return (c2 > 0.) ? c1 + FastMath.exp(2 * shape / mu) * c2 : c1;
  }
580199
public static double cdf(double x, double mu, double sigma, double lambda) {
    if(x == Double.NEGATIVE_INFINITY) {
      return 0.;
    }
    if(x == Double.POSITIVE_INFINITY) {
      return 1.;
    }
    final double u = lambda * (x - mu);
    final double v = lambda * sigma;
    final double v2 = v * v;
    final double logphi = FastMath.log(NormalDistribution.cdf(u, v2, v));
    return NormalDistribution.cdf(u, 0., v) - FastMath.exp(-u + v2 * .5 + logphi);
  }
82123
@Override
    public INDArray rand(int[] shape, Distribution r) {
        INDArray ret = r.sample(shape);
        return ret;
    }
1281840
def pdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)    
        return self.pdf_internal(mu, df=self.df0, loc=self.loc0, scale=self.scale0, gamma=self.gamma0)
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;
  }
857319
public static double logcdf(double x, double k, double theta, double shift) {
    x = (x - shift);
    return x <= 0. ? -Double.NEGATIVE_INFINITY : GammaDistribution.logregularizedGammaP(k, FastMath.log1p(x) * theta);
  }
182332
public static double cdf(double x, double mu, double sigma) {
    if(x <= 0.) {
      return 0.;
    }
    return .5 * (1 + NormalDistribution.erf((FastMath.log(x) - mu) / (MathUtil.SQRT2 * sigma)));
  }
1321484
def rand_student_t(df, mu=0, std=1):
    

    x = random.gauss(0, std)
    y = 2.0*random.gammavariate(0.5 * df, 2.0)
    return x / (math.sqrt(y / df)) + mu
698450
def probability_density(self, X):
        
        self.check_fit()
        return norm.pdf(X, loc=self.mean, scale=self.std)
905459
public static double logpdf(double x, double location, double shape) {
    final double v = (x - location) / shape;
    return -FastMath.log(Math.PI * shape * (1 + v * v));
  }
691549
public static double pdf(double val, double loc, double scale, double shape1, double shape2) {
    val = (val - loc) / scale;
    final double logc = logcdf(val, shape1, shape2);
    if(shape1 == 1.) {
      // Then val will usually become 0.
      return val >= 1 ? 0 : FastMath.exp(logc * (1. - shape2)) / scale;
    }
    if(shape1 != 0.) {
      val = shape1 * val;
      if(val >= 1) {
        return 0;
      }
      val = (1. - 1. / shape1) * FastMath.log1p(-val);
    }
    if(Double.isInfinite(val)) {
      return 0;
    }
    val = FastMath.exp(-val);
    return Double.isInfinite(val) ? 0. : val / scale * FastMath.exp(logc * (1. - shape2));
  }
551194
def cumulative_distribution(self, X):
        
        self.check_fit()

        # Wrapper for pdf to accept vector as args
        def func(*args):
            return self.probability_density(list(args))

        # Lower bound for integral, to split significant part from tail
        lower_bound = self.get_lower_bound()

        ranges = [[lower_bound, val] for val in X]
        return integrate.nquad(func, ranges)[0]
769771
@Override
    public INDArray rand(int[] shape, org.nd4j.linalg.api.rng.Random r) {
        INDArray ret = r.nextDouble(shape);
        return ret;
    }
14913
public static long[] squeeze(long[] shape) {
        if (isColumnVectorShape(shape))
            return shape;

        List<Long> ret = new ArrayList<>();

        //strip all but last dimension
        for (int i = 0; i < shape.length; i++)
            if (shape[i] != 1)
                ret.add(shape[i]);
        return ArrayUtil.toArrayLong(ret);
    }
780473
def pdf_new(self, x, mu, sigma, skw):
        
        if skw > 1 or skw < -1:
            print("skewness %s out of range" % skw)
            skw = 1.
        e, w, a = self.map_mu_sigma_skw(mu, sigma, skw)
        pdf = self.pdf(x, e, w, a)
        return pdf
1150709
public static double pdf(double x, double k, double theta, double shift) {
    if(x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY) {
      return 0.;
    }
    if(x != x) {
      return Double.NaN;
    }
    x = (x - shift) * theta;
    final double ex = FastMath.exp(x);
    return ex < Double.POSITIVE_INFINITY ? FastMath.exp(k * x - ex - GammaDistribution.logGamma(k)) * theta : 0.;
  }
172921
public static double pdf(double x, double location, double shape) {
    final double v = (x - location) / shape;
    return 1. / (Math.PI * shape * (1 + v * v));
  }