public static double dirichletPdf ( double [ ] pi , double a ) { double probability = 1.0 ; int piLength = pi . length ; for ( int i = 0 ; i < piLength ; ++ i ) { probability *= Math . pow ( pi [ i ] , a - 1 ) ; } double sumAi = piLength * a ; double productGammaAi = Math . pow ( gamma ( a ) , piLength ) ; probability *= gamma ( sumAi ) / productGammaAi ; return probability ; }
Implementation for single alpha value .