Using R, If you have 5 red marble, 4 green marble, and 8 yellow marble. If two marbles are selected randomly what is the probability that they match? What is the probability that a red pair is chosen?
We can use choose function to calculate ncr.
#proability that two marbles match
# 5 red 4 green 8 yellow
#5C2
ans1 <- choose(5,2)
#4C2
ans2 <- choose(4,2)
#8C2
ans3 <- choose(8,2)
ans4= ans1+ans2+ans3
#total probability 5+4+8= 17C2
ans5 <- choose(17,2)
print(ans4/ans5)
#proability that two red marbles match
#5C2/17C2
print(ans1/ans5)
Get Answers For Free
Most questions answered within 1 hours.