Rolling Dice Probabilities

We will answer the following questions using the Prob Library in R:

1) A dice is rolled once. Find the probability of obtaining

a) the number 3

b) an odd number

c) a number greater than 2

Solution

a) P(3) = 0.17

R Code:

> require(prob)

> S<-rolldie(1,makespace = T)

> A<-subset(S,X1==3)

> Prob(A)

[1] 0.1666667

> round(Prob(A),digits=2) # the function round() rounds off the probability to 2 decimal places.

[1] 0.17

b) P(X is an odd number) = P(X = 1 or X = 3 or X = 5) = 0.5

R Code:

> S<-rolldie(1,makespace = T)

> B <-subset(S,X1==1 | X1==3 | X1==5)

> Prob(B)

[1] 0.5

c) P(X > 2) = 0.67

R Code:

> S<-rolldie(1,makespace = T)

> C <-subset(S,X1>2)

> Prob(C)

[1] 0.6666667

> round(Prob(C), digits=2)

[1] 0.67


2) Two dice are rolled together. Find the probability of obtaining

a) two different digits

b) a difference of 1

c) a sum of 10

Solution

a) P(X1 is not equal to X2) = 0.83

R Code:

> S<-rolldie(2,makespace = T)

> D <-subset(S,X1!=X2)

> D

X1 X2 probs

2 2 1 0.02777778

3 3 1 0.02777778

4 4 1 0.02777778

5 5 1 0.02777778

6 6 1 0.02777778

7 1 2 0.02777778

9 3 2 0.02777778

10 4 2 0.02777778

11 5 2 0.02777778

12 6 2 0.02777778

13 1 3 0.02777778

14 2 3 0.02777778

16 4 3 0.02777778

17 5 3 0.02777778

18 6 3 0.02777778

19 1 4 0.02777778

20 2 4 0.02777778

21 3 4 0.02777778

23 5 4 0.02777778

24 6 4 0.02777778

25 1 5 0.02777778

26 2 5 0.02777778

27 3 5 0.02777778

28 4 5 0.02777778

30 6 5 0.02777778

31 1 6 0.02777778

32 2 6 0.02777778

33 3 6 0.02777778

34 4 6 0.02777778

35 5 6 0.02777778

> Prob(D)

[1] 0.8333333

>round(Prob(D),digits=2)

[1] 0.83


b) P(|X1 - X2 |= 1) = 0.28

R Code:

> E <-subset(S,abs(X1-X2)==1)

> E

X1 X2 probs

2 2 1 0.02777778

7 1 2 0.02777778

9 3 2 0.02777778

14 2 3 0.02777778

16 4 3 0.02777778

21 3 4 0.02777778

23 5 4 0.02777778

28 4 5 0.02777778

30 6 5 0.02777778

35 5 6 0.02777778

> Prob(E)

[1] 0.2777778

> round(Prob(E),digits = 2)

[1] 0.28


c) P(X1 + X2 = 10) = 0.08

R Code:

> F <-subset(S,X1+X2==10)

> F

X1 X2 probs

24 6 4 0.02777778

29 5 5 0.02777778

34 4 6 0.02777778

> Prob(F)

[1] 0.08333333

> round(Prob(F),digits = 2)

[1] 0.08


3) What is the conditional probability that a die lands on a prime number, given that it lands on an odd number?

P(Prime given Odd) = 0.67

R Code:

> S<-rolldie(1,makespace = T)

> A <-subset(S,X1==2 | X1==3 | X1==5)

> B <-subset(S,X1==1 | X1==3 | X1==5)

> Prob(A, given=B)

[1] 0.6666667

> round(Prob(A, given=B),digits=2)

[1] 0.67

Alternatively, we can solve this probability as follows.



> S<-rolldie(1,makespace=T)

> A <-subset(S,X1==2|X1==3|X1==5)

> B <-subset(S,X1==1|X1==3|X1==5)

> Prob(intersect(A,B))/Prob(B)

[1] 0.6666667

> round(Prob(intersect(A,B))/Prob(B),digits=2)

[1] 0.67