DATA 605 FUNDAMENTALS OF COMPUTATIONAL MATHEMATICS

Discussion W5: 1.2 #11

Kyle Gilde

9/27/2017

## 
## Attaching package: 'combinat'
## The following object is masked from 'package:utils':
## 
##     combn
## 
## Rmetrics Package fBasics
## Analysing Markets and calculating Basic Statistics
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: info@rmetrics.org
## 
## Rmetrics Package fOptions
## Pricing and Evaluating Basic Options
## Copyright (C) 2005-2014 Rmetrics Association Zurich
## Educational Software for Financial Engineering and Computational Science
## Rmetrics is free software and comes with ABSOLUTELY NO WARRANTY.
## https://www.rmetrics.org --- Mail to: info@rmetrics.org
## 
## Attaching package: 'VGAM'
## The following object is masked from 'package:hypergeo':
## 
##     is.zero
## The following object is masked from 'package:fAsianOptions':
## 
##     erf
## prob 
## TRUE

11. What odds should a person give in favor of the following events?

  1. A card chosen at random from a 52-card deck is an ace.

In R

(Aces <- sum(cards()$rank == "A"))
## [1] 4
(ncards <- nrow(cards()))
## [1] 52
Aces/ncards
## [1] 0.07692308

P(A) = 4/52 = 1/13 Therefore, the odds are 1:12

  1. Two heads will turn up when a coin is tossed twice.

In R


(samp_space <- tosscoin(2))
##   toss1 toss2
## 1     H     H
## 2     T     H
## 3     H     T
## 4     T     T

(Nsamp_space <- nrow(samp_space))
## [1] 4
(desired_outcome <- nrow(subset(samp_space, toss1 == "H" & toss2 == "H")))
## [1] 1

desired_outcome/Nsamp_space
## [1] 0.25

P(A) = 1/4

Therefore, the odds are 1:3.

  1. Boxcars (two sixes) will turn up when two dice are rolled
(samp_space <- rolldie(2))
##    X1 X2
## 1   1  1
## 2   2  1
## 3   3  1
## 4   4  1
## 5   5  1
## 6   6  1
## 7   1  2
## 8   2  2
## 9   3  2
## 10  4  2
## 11  5  2
## 12  6  2
## 13  1  3
## 14  2  3
## 15  3  3
## 16  4  3
## 17  5  3
## 18  6  3
## 19  1  4
## 20  2  4
## 21  3  4
## 22  4  4
## 23  5  4
## 24  6  4
## 25  1  5
## 26  2  5
## 27  3  5
## 28  4  5
## 29  5  5
## 30  6  5
## 31  1  6
## 32  2  6
## 33  3  6
## 34  4  6
## 35  5  6
## 36  6  6

(Nsamp_space <- nrow(samp_space))
## [1] 36
(desired_outcome <- nrow(subset(samp_space, X1 == 6 & X2 == 6)))
## [1] 1

desired_outcome/Nsamp_space
## [1] 0.02777778

P(A) = 1/36 Therefore, the odds are 1:35.