public static double logpdf(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 Double.NEGATIVE_INFINITY;
  }
  if (val == 0.) {
    return (alpha > 1.) ? Double.NEGATIVE_INFINITY : (alpha < 1.) ? Double.POSITIVE_INFINITY : Math.log(beta);
  }
  if (val == 1.) {
    return (beta > 1.) ? Double.NEGATIVE_INFINITY : (beta < 1.) ? Double.POSITIVE_INFINITY : Math.log(alpha);
  }
  return -logBeta(alpha,beta) + Math.log(val) * (alpha - 1) + Math.log1p(-val) * (beta - 1);
}

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