void get_Dirichlet(double a[],int num){
typedef std::mt19937 G;
typedef std::gamma_distribution<> D;
G g; // seed if you want with integral argument
double k = 1; // http://en.wikipedia.org/wiki/Gamma_distribution
double theta = 1;
double sm=0;
for(int i=0;i<num;i++){
D d(k, theta);
a[i]=d(g);
sm+=a[i];
}
for(int i=0;i<num;i++)a[i]/=sm;
}