Discrete Probabilities with R

#ICYDK: Probability in general can be thought of as the chances of a particular event happening, say winning or loosing a game, the cliche’ example of  tossing a coin and what not.

When I say chance of an event, I mean the percentage of times that event would turn out if I were to do that experiment a large number of times.

Let us consider a box that contains 13 balls, out of which 5 are Blue and 8 are Red. What will be the probability of picking a red ball? Let’s see, there are 8 red balls and a total of 13 balls, so by intuition I’d say 8/13.

The most basic mathematical definition of probability will be something like:

 Probability(A) = P(A) = (Count of a likely event) / (Total number of outcomes)

According to the above formula,

P(Red ball) = 8 / (8+5) = 8/13 = 0.615 = 61.5%

P(Blue ball) = 5 / (8+5) = 5/13 = 0.384 = 38.4%

Now we’ll try to calculate it in R.

Step 1: Creating the box which contains the balls.

box https://goo.gl/b81T8B