Static version of the t distribution's PDF.

@param val value to evaluate
@param v degrees of freedom
@return f(val,v)
426702
public static double pdf(double val, int v) {
    // TODO: improve precision by computing "exp" last?
    return FastMath.exp(GammaDistribution.logGamma((v + 1) * .5) - GammaDistribution.logGamma(v * .5)) //
        * (1 / FastMath.sqrt(v * Math.PI)) * FastMath.pow(1 + (val * val) / v, -((v + 1) * .5));
  }
627251
public static final Color getColorForValue(double val) {
    // Color positions
    double[] pos = new double[] { 0.0, 0.6, 0.8, 1.0 };
    // Colors at these positions
    Color[] cols = new Color[] { new Color(0.0f, 0.0f, 0.0f, 0.6f), new Color(0.0f, 0.0f, 1.0f, 0.8f), new Color(1.0f, 0.0f, 0.0f, 0.9f), new Color(1.0f, 1.0f, 0.0f, 1.0f) };
    assert (pos.length == cols.length);
    if(val < pos[0]) {
      val = pos[0];
    }
    // Linear interpolation:
    for(int i = 1; i < pos.length; i++) {
      if(val <= pos[i]) {
        Color prev = cols[i - 1];
        Color next = cols[i];
        final double mix = (val - pos[i - 1]) / (pos[i] - pos[i - 1]);
        final int r = (int) ((1 - mix) * prev.getRed() + mix * next.getRed());
        final int g = (int) ((1 - mix) * prev.getGreen() + mix * next.getGreen());
        final int b = (int) ((1 - mix) * prev.getBlue() + mix * next.getBlue());
        final int a = (int) ((1 - mix) * prev.getAlpha() + mix * next.getAlpha());
        Color col = new Color(r, g, b, a);
        return col;
      }
    }
    return cols[cols.length - 1];
  }
361630
public static BigDecimal bd(final String val) {
        return val != null && val.length() > 0 ? new BigDecimal(val) : null;
    }
969807
def pdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)             
        return (1.0/float(self.sigma0))*np.exp(-(0.5*(mu-self.mu0)**2)/float(self.sigma0**2))
765477
public static double quantile(double val, double k, double lambda, double theta) {
    if(val < 0.0 || val > 1.0) {
      return Double.NaN;
    }
    else if(val == 0) {
      return 0.0;
    }
    else if(val == 1) {
      return Double.POSITIVE_INFINITY;
    }
    else {
      return theta + lambda * FastMath.pow(-FastMath.log(1.0 - val), 1.0 / k);
    }
  }
25572
public T divide( double val ) {
        T ret = createLike();
        ops.divide(mat,val,ret.getMatrix());
        return ret;
    }
654382
public static double quantile(double val, double shape, double location, double scale) {
    return val < 0 || val > 1 ? Double.NaN : scale * FastMath.pow(val / (1. - val), 1. / shape) + location;
  }
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;
  }
314153
public static double quantile(double val, double sigma) {
    if(!(val >= 0.) || !(val <= 1.)) {
      return Double.NaN;
    }
    if(val == 0.) {
      return 0.;
    }
    if(val == 1.) {
      return Double.POSITIVE_INFINITY;
    }
    return sigma * FastMath.sqrt(-2. * FastMath.log(1. - val));
  }
1199217
public static double logpdf(double val, double rate) {
    return FastMath.log(.5 * rate) - rate * Math.abs(val);
  }
213993
public static double logpdf(double val, double loc, double scale, double shape) {
    val = (val - loc) / scale;
    double e = FastMath.exp(-val);
    return -(val + (shape + 1.0) * FastMath.log1p(e)) + FastMath.log(shape);
  }
848707
@Override
	public RandomVariable getVolatility(int timeIndex, int liborIndex) {
		// Create a very simple volatility model here
		double time             = getTimeDiscretization().getTime(timeIndex);
		double maturity         = getLiborPeriodDiscretization().getTime(liborIndex);
		double timeToMaturity   = maturity-time;

		double volatilityInstanteaneous;
		if(timeToMaturity <= 0)
		{
			volatilityInstanteaneous = 0;   // This forward rate is already fixed, no volatility
		}
		else
		{
			volatilityInstanteaneous = a * Math.exp(-b * timeToMaturity);
		}

		return new RandomVariable(getTimeDiscretization().getTime(timeIndex), volatilityInstanteaneous);
	}
491524
public static float parseFloat(String val, float defVal){
        if(TextUtils.isEmpty(val)) return defVal;
        try{
            return Float.parseFloat(val);
        }catch (NumberFormatException e){
            return defVal;
        }
    }
1063270
public static double quantile(double val, double loc, double scale, double shape) {
    return loc - scale * FastMath.log(FastMath.exp(FastMath.log(val) / -shape) - 1);
  }
1297083
public static double logpdf(double val, double shape, double location, double scale) {
    if(val < location) {
      return Double.NEGATIVE_INFINITY;
    }
    val = (val - location) / scale;
    final double lval = FastMath.log(val);
    if(lval == Double.POSITIVE_INFINITY) {
      return Double.NEGATIVE_INFINITY;
    }
    return FastMath.log(shape / scale) + (shape - 1.) * lval //
        - 2. * FastMath.log1p(FastMath.exp(lval * shape));
  }
1180635
public static double cdf(double val, double loc, double scale, double shape) {
    val = (val - loc) / scale;
    return FastMath.pow(1. + FastMath.exp(-val), -shape);
  }
605779
protected double decisionFunction(int v)
    {
        double sum = 0;
        for(int i = 0; i < vecs.size(); i++)
            if(alphas[i] > 0)
                sum += alphas[i] * label[i] * kEval(v, i);

        return sum;
    }