INTRODUCTION
- Monte Carlo Simulation
- Resampling Methods (bootstrap, permutation, cross-validation)
- Unsupervised learning (clustering, dimension reduction)
- High-dimensional data (penalized regression)
Coin toss experiment
- 4H in a row » HHHHT | THHHH » 2 possibilities
- All » 2*2*2*2*2 = 2^5 = 32 possibilities
- Probability theory: Pr (4H in a row| 5 tosses) = = 0.0625 ~= 6%
Monty Hall experiment
Simulation
- Imitation of operation of real-world process or system over time
- Developed model represents the system, simulation represents the operation
- Only simulation If the system can’t be solved analytically (no/complex mathematical proof)
- MC: computer experiment involving random sampling from probability distributions
- Pseudo random number generators in R:
o Simulation for discrete random variables
▪ sample() function (data/vector, size, replace)
▪ Bernoulli, binomial, multinomial, Poisson distribution
o Simulation for continuous random variables
▪ rnorm() function (normal distribution)
, Monte Carlo simulation
1. How to?
o Input (number of trials, random or not, if random: what probability distribution?)
o Output of interest
o Model relating output to input
2. Pseudo code
o Name your function and specify arguments
o Define input and output of your function
o Show underlying sequence of steps taken
▪ Use statements: WHILE … DO, REPEAT, FOR … to … DO, IF … THEN … ELSE
o Make sure your function returns the output
3. Implement MC simulation in R
Illustrative exam question
- Tossing a coin 6 times, what is the probability of obtaining exactly 4 times tails in a row?
o Input: n tosses, output: probability k times head
o Pr(4T in a row|6 tosses) = Nr of ways 4T in a row can happen / Total nr of outcomes =
^6 = = 0,078125
- Give pseudo code for a MC simulation experiment to approximate the probability of
obtaining exactly k times head when tossing a coin n times
o Input: n tosses, output: probability k times head, MC » repeat experiment s times
o Probability = Number of ‘hits’ Pr(4T in a row|6 tosses) / number of times experiment