I need a Dirichlet distribution and I am using numpy.random.dirichlet. when I give alpha=[1,1,1,1] according to the Dirichlet PDF formula, it should result a uniform function. but it doesn't give me a uniform vector. anybody knows why?
            Asked
            
        
        
            Active
            
        
            Viewed 4,098 times
        
    1 Answers
3
            
            
        As far as I can tell, the numpy.random.dirichlet function works as intended. I think you may be slightly misunderstanding what the Dirichlet distribution is. 
A k-dimensional Dirichlet distribution will have k parameters (x_1 through to x_k), which must all sum to 1. If you try sum(np.random.dirichlet([1, 1, 1, 1])), the result will always be 1 (give or take some rounding error). So while np.random.dirichlet([1, 1, 1, 1])) is indeed uniform on its support, this support is constrained by the requirement that x_1 + x_2 + x_3 + x_4 = 1, and the output array will not be Unif(0, 1) distributed.
This article gives a relatively simple and non-technical explanation of the concept.
        James L
        
- 138
 - 1
 - 5