Since the town is small, they can’t afford cameras or other automated counting techniques. They have to use observers to go out and count the traffic in half hour periods. They figure that they can afford 12 half hour periods of observation at each intersection during the upcoming work week. From their experience living in the town they know the following general items about traffic in the town.

  • midnight to 5:30 has very low traffic.
  • 6:00 to 9:00 has work commuter traffic.
  • 11:30 to 1:00 has lunch traffic.
  • 4:30 to 7:00 has commuter traffic
  • other times have low traffic

Answer the following questions

  • What is the population?
  • What are the population units?
  • What is being measured on each unit?
  • Write code that would do a simple random sample of 12 half hour periods throughout a week?
  • Apply that set of randomly sampled half hours to each intersection (see code below).
  • Report the mean of your randomly sampled half hours.
  • What other sampling ideas do you have?
# Here is the code to read in the data
data.dir = "http://byuistats.github.io/M330/data"
i1 = read.csv(file.path(data.dir,"intersection_1.csv"),stringsAsFactors = FALSE)
i2 = read.csv(file.path(data.dir,"intersection_2.csv"),stringsAsFactors = FALSE)
# now how would you pull your half hours?
# remember we have 24*2*5 = 240 possible half hours in our week
random_rows = sample(240,12)
mean(i1[random_rows,"counts"])
mean(i2[random_rows,"counts"])