Download presentation
Presentation is loading. Please wait.
Published byLadislav Musil Modified over 5 years ago
1
Simulation allows us to perform “experiments” without actually having to do the experiments in real life...this is done through the use of random numbers either generated from a random number table or from a computer program (such as R). random number tables have many thousands of digits (0-9) all occurring in approximately equal numbers in the table – thus when choosing a digit at random it can be done with the uniform distribution (Prob(any one digit is chosen)=.1 ) Then these digits can be used to simulate other distributions like the Bernoulli, binomial, etc. try some examples simulate the toss of a fair coin once; 5 times; etc. simulate a B(5,.5) r.v. (see the bottom of p.139 for a better way) “one son” policy in a country – can we simulate it to answer: what would be the average number of children in a family? what would be the ratio of births of girls to births of boys? show the same methods in R using the r functions...
2
HW: Read section and try #4. 77 and 4. 78. Notice that 4
HW: Read section and try #4.77 and Notice that 4.77 asks you to simulate 120 rolls of a balanced die. Using the random number table is a possibility, but let’s try R also... try the following code: #the sample function allows you to randomly sample from #a set of numbers with equal probability assigned to each #number. thus in the line below we get a sample of 100 #of the digits 1-6, replace=T making sure of equal probs. x<-sample(c(1,2,3,4,5,6),100, replace=T) table(x) #the table function gives a frequency distribution of the #vector x – in this case shows how many 1’s, 2’s, etc. #were randomly selected. to handle the example on p.140 #create a vector of probs to go with the vector of values prvect<-c(.082,.205,.256,.214,.134,.067,.028,.01,.003,.001) y<-c(0:9) x<-sample(y,size=100,replace=T,prob=prvect)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.