question: public static double pdf ( double x , double shape , double scale ) { if ( x < 0 ) return 0 ; if ( x == 0 ) { if ( shape == 1.0 ) return 1.0 / scale ; else return 0.0 ; } if ( shape == 0.0 ) return 1.0 / x ; if ( shape == - 0.5 ) { return Math . sqrt ( x ) ; } final double xs = x / scale ; if ( shape == 1.0 ) { return Math . exp ( - xs ) / scale ; } final double a = Math . exp ( ( shape - 1.0 ) * Math . log ( xs ) - xs - GammaFunction . lnGamma ( shape ) ) ; return a / scale ; }
target:  probability density function of the Gamma distribution