public static double pdf(double val,double alpha,double beta){
  if (alpha <= 0. || beta <= 0. || Double.isNaN(alpha) || Double.isNaN(beta) || Double.isNaN(val)) {
    return Double.NaN;
  }
  if (val < 0. || val > 1.) {
    return 0.;
  }
  if (val == 0.) {
    return (alpha > 1.) ? 0. : (alpha < 1.) ? Double.POSITIVE_INFINITY : beta;
  }
  if (val == 1.) {
    return (beta > 1.) ? 0. : (beta < 1.) ? Double.POSITIVE_INFINITY : alpha;
  }
  return Math.exp(-logBeta(alpha,beta) + Math.log(val) * (alpha - 1) + Math.log1p(-val) * (beta - 1));
}

public static double pdf ( double val , double alpha , double beta ) { if ( alpha <= 0. || beta <= 0. || Double . isNaN ( alpha ) || Double . isNaN ( beta ) || Double . isNaN ( val ) ) { return Double . NaN ; } if ( val < 0. || val > 1. ) { return 0. ; } if ( val == 0. ) { return ( alpha > 1. ) ? 0. : ( alpha < 1. ) ? Double . POSITIVE_INFINITY : beta ; } if ( val == 1. ) { return ( beta > 1. ) ? 0. : ( beta < 1. ) ? Double . POSITIVE_INFINITY : alpha ; } return Math . exp ( - logBeta ( alpha , beta ) + Math . log ( val ) * ( alpha - 1 ) + Math . log1p ( - val ) * ( beta - 1 ) ) ; }
static version of the pdf of the beta distribution
