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: rDist=randi(N,[10,S]
);
Now that I have the marbles that I've picked, I create another 10xS cell array and want to fill that cell array with the colors of the marbles based on the number picked. That is, let's say I have 10 marbles and 7 are red and 3 are green. If the PRNG picks 1:7, I want the results cell array to say "red" and if it chooses 8:10, I want "green" in the corresponding positions. I can do this for finite numbers, but I want to extend this to K marble colors with any number of distributions of marble colors. Can you offer any help?
My "finite" solution for 2 marble types is below:
for lc=1:10*S
counter=0;
if (rDist(lc)>=1 && (rDist(lc)<=Probabilities(1)))
Results{lc}=Color{1};
end
counter=Probabilities(1);
if (rDist(lc)>counter && (rDist(lc)<=counter+Probabilities(2)))
Results{lc}=Color{2};
end
end