I have asked similar question three day ago[The old question]. it was incorrectly marked as duplicated. This time I make this question more general and closer to reality.
I want to build a model of N geological layers. The layers can be four types of rocks, which have probabilities to appear in a layer of p1, p2, p3 and p4 respectively (obviously p1+p2+p3+p4=1). Let n1, n2, n3, and n4 be the numbers of layers for the four types of rocks respectively, and obviously n1+n2+n3+n4=N and n1, n2, n3 and n4 must be an integer between [0, N]. Let use parameter initialization: N=40, p1=60%, p2=25%,p3=10%, p4=5%. I want to generate a large population of this geological model satisfying above conditions and the model should be in form of {n1i,n2i,n3i,n4i}: {{1, 9, 4, 26}, {13, 16, 3, 8}, {7, 14, 7, 12}, {11, 7, 6, 16}, {17, 13, 1, 9}, {21, 1, 1, 17}, …}
To check your results: Mean[n1]=24; Mean[n2]=10; Mean[n3]=4; and Mean[n4]=2. The "=" should be approximately equal.
Thanks a lot!

