def pdf(alphas):
    '''Returns a Dirichlet PDF function'''
    alphap = alphas - 1
    c = np.exp(gammaln(alphas.sum()) - gammaln(alphas).sum())
    def dirichlet(xs):
        '''N x K array'''
        return c * (xs**alphap).prod(axis=1)
    return dirichlet
def pdf ( alphas ) : alphap = alphas - 1 c = np . exp ( gammaln ( alphas . sum ( ) ) - gammaln ( alphas ) . sum ( ) ) def dirichlet ( xs ) : return c * ( xs ** alphap ) . prod ( axis = 1 ) return dirichlet
Returns a Dirichlet PDF function