/** * Returns the gamma function <tt>gamma(x)</tt>. */ public static double gamma(double x) { x = logGamma(x); // if (x > Math.log(Double.MAX_VALUE)) return Double.MAX_VALUE; return Math.exp(x); }
/** * Returns the gamma function <tt>gamma(x)</tt>. */ public static double gamma(double x) { x = logGamma(x); // if (x > Math.log(Double.MAX_VALUE)) return Double.MAX_VALUE; return Math.exp(x); }
/** * Sets the distribution parameter. * * @param freedom * degrees of freedom. * @throws IllegalArgumentException * if <tt>freedom <= 0.0</tt>. */ public void setState(double freedom) { if (freedom <= 0.0) throw new IllegalArgumentException(); this.freedom = freedom; double val = Fun.logGamma((freedom + 1) / 2) - Fun.logGamma(freedom / 2); this.TERM = Math.exp(val) / Math.sqrt(Math.PI * freedom); }
/** * Sets the distribution parameter. * * @param freedom * degrees of freedom. * @throws IllegalArgumentException * if <tt>freedom <= 0.0</tt>. */ public void setState(double freedom) { if (freedom <= 0.0) throw new IllegalArgumentException(); this.freedom = freedom; double val = Fun.logGamma((freedom + 1) / 2) - Fun.logGamma(freedom / 2); this.TERM = Math.exp(val) / Math.sqrt(Math.PI * freedom); }
/** * Returns the probability distribution function. */ public double pdf(double x) { if (x <= 0.0) throw new IllegalArgumentException(); double logGamma = Fun.logGamma(freedom / 2.0); return Math.exp((freedom / 2.0 - 1.0) * Math.log(x / 2.0) - x / 2.0 - logGamma) / 2.0; }
/** * Returns the probability distribution function. */ public double pdf(double x) { if (x <= 0.0) throw new IllegalArgumentException(); double logGamma = Fun.logGamma(freedom / 2.0); return Math.exp((freedom / 2.0 - 1.0) * Math.log(x / 2.0) - x / 2.0 - logGamma) / 2.0; }
/** * Returns the probability distribution function. */ public double pdf(double x) { if (x < 0) throw new IllegalArgumentException(); if (x == 0) { if (alpha == 1.0) return 1.0 / lambda; else return 0.0; } if (alpha == 1.0) return Math.exp(-x / lambda) / lambda; return Math.exp((alpha - 1.0) * Math.log(x / lambda) - x / lambda - Fun.logGamma(alpha)) / lambda; }
/** * Returns the probability distribution function. */ public double pdf(double x) { if (x < 0) throw new IllegalArgumentException(); if (x == 0) { if (alpha == 1.0) return 1.0 / lambda; else return 0.0; } if (alpha == 1.0) return Math.exp(-x / lambda) / lambda; return Math.exp((alpha - 1.0) * Math.log(x / lambda) - x / lambda - Fun.logGamma(alpha)) / lambda; }