Random Weighted: Red, White, Blue, and Purple

You are creating a game to behaves as if randomly selecting different colors of balls from container. The container is roughly infinitely large, with that many more many balls inside of it. The interesting thing though is that the number of balls in the container aren't evenly distributed. Your game should accurately reflect, probabilistically, the distribution of ball colors. That is, as the number of selections increases, the selected balls should reflect closer to the original distribution of ball colors in the container.

The distribution of balls is:

  • 38% red
  • 37% white
  • 24% blue
  • 1% purple

Answer

Answers are hidden from search engines.
coding language=java algorithm