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 Math.exp(-x * theta) * theta;
  }
  final double xt=x * theta;
  return (xt == Double.POSITIVE_INFINITY) ? 0. : Math.exp((k - 1.0) * Math.log(xt) - xt - logGamma(k)) * theta;
}

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 Math . exp ( - x * theta ) * theta ; } final double xt = x * theta ; return ( xt == Double . POSITIVE_INFINITY ) ? 0. : Math . exp ( ( k - 1.0 ) * Math . log ( xt ) - xt - logGamma ( k ) ) * theta ; }
gamma distribution pdf ( with 0 . 0 for x & lt ; 0 )
