Q：Simulation of an arbitrary bag of marbles 
Q：任意包弹子的模拟 
So, I'm trying to simulate an arbitrary model of a bag of marbles (with replacement, if that makes a difference in how this works) and am running into issues displaying the results. How I have it set up is the code asks for how many marbles are in the bag, the how many you would like to pick, and then how many different colors there are. (Defined as N, S, and k respectively).
I then go through a loop between 1 and k in a cell array to name the colors of the marbles and then create a second array that simulates the probabilities by asking how many of each color there is in the bag.
I then generate a random matrix that simulates 10 "games" (ie: My "finite" solution for 2 marble types is below:

所以，我试图模拟一个任意模型的一包大理石（更换，如果这使得这如何工作的差异），并运行到显示结果的问题。 How I have it set up is the code asks for how many marbles are in the bag, the how many you would like to pick, and then how many different colors there are. (Defined as N, S, and k respectively).
I then go through a loop between 1 and k in a cell array to name the colors of the marbles and then create a second array that simulates the probabilities by asking how many of each color there is in the bag.
I then generate a random matrix that simulates 10 "games" (ie: 我的“有限”2大理石类型的解决方案如下：

answer1：  回答1： 
You can calculate the intervals that correspond to each color with cumsum. Then you need to find which interval each entry of rDist belongs to.
You could also do this with quantiz from the communication systems toolbox or randSample from the statistics and machine learning toolbox. Finally, you could use the more confusing oneliner out = names(arrayfun( @(x)( find(cumsumCounts >= x, 1) ), rDist)); 
你可以计算间隔对应每个颜色的Cumsum。然后，你需要找到它的每一项都属于区间rdist。
你也可以做这个量化从通信系统工具箱或randsample从机器学习和统计工具箱。最后，你可以使用更多的混乱的一套=名称（arrayfun（@（x）（找到（cumsumcounts >；= x，1）），rdist））； 
matlab statistics probability ndimensional 