Home

Pick-a-Ball Simulation (Conditional Probability)

Here we simulate the following situation: you randomly select first a basket (of two baskets A ja B) and then pick a ball out of that basket. In the baskets there are a certain number of red balls and white balls.

You see that the ball you got is red.

Question: which is the probability that the ball was in basket A? Calculate first, then simulate below to see if your result seems good.

The simulation idea: you pick a random ball from a random basket and save the color and original basket of the ball. Repeat the procedure a certain number of times. Then you count all the results with red balls and calculate the ratio of #(red balls out of A) and #(all red ones).

Type values of your choice to the text fields below:

Number of red balls in basket A:
Number of white balls in basket A:
Number of red balls in basket B:
Number of white balls in basket B:
Number of trials: