Skip to content

Instantly share code, notes, and snippets.

@mick001
Created August 28, 2015 18:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mick001/d88476a6c85b73b1419a to your computer and use it in GitHub Desktop.
Save mick001/d88476a6c85b73b1419a to your computer and use it in GitHub Desktop.
Estimating arrival times of people in a shop using R. Part 3. Full article at: http://www.firsttimeprogrammer.blogspot.com/2015/07/estimating-arrival-times-of-people-in.html
#-------------------------------------------------------------------------------
# Compare simulated to obseved data
#-------------------------------------------------------------------------------
# Let's compare observed data with simulated data
# Comparative boxplot
boxplot(interarrivals,simulated.min,xlab='Minutes',col=c('cyan','chartreuse'),
border=c('blue','seagreen'),names=c('Observed','Simulated'),
main='Interarrival times',notch=TRUE,horizontal=TRUE)
# Comparative histograms
hist(simulated.min,col='chartreuse',breaks=breaks.points1,xlab=x.lab,ylab=y.lab,
main=main.lab,border='seagreen',density=20,angle=30)
hist(interarrivals,col='cyan',breaks=breaks.points1,border='blue',
density=20,angle=160,add=TRUE)
# Add a legend
legend("topright",c("Simulated","Observed"), col=c("seagreen", "blue"), lwd=10)
# Comparative histograms of number of people per arrival
hist(people.per.arr,xlab='No. of people',breaks=break.points2,
main='Simulated number of people per arrival',col='chartreuse',
border='seagreen',density=30,angle=30)
hist(data$pers,breaks=break.points2,col='red',border='red4',density=30,
angle=160,add=TRUE)
# Add a legend
legend("topright",c("Simulated","Observed"), col=c("seagreen", "red"), lwd=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment