Skip to main content

Introduction to Data Science Version 3

Chapter 12 Popularity Contest

In the previous chapter we found that arrival times of tweets on a given topic seem to fit a Poisson distribution. Armed with that knowledge we can now develop a test to compare two different Twitter topics to see which one is more popular (or at least which one has a higher posting rate). We will use our knowledge of sampling distributions to understand the logic of the test.

Sources.

Barplots
Poisson Distribution
R Functions Used in this Chapter
R Script - Create Vector of Probabilities From Delay Times
# Like ArrivalProbability, but works with unsorted list
# of delay times
DelayProbability<-function(delays, increment, max)
{
# Initialize an empty vector
plist <- NULL
# Probability is defined over the size of this sample
# of arrival times
delayLen <- length(delays)
# May not be necessary, but checks for input mistake
if (increment>max) {return(NULL)}
for (i in seq(increment, max, by=increment))
{
# logical test <=i provides list of TRUEs and FALSEs
# of length = timeLen, then sum() counts the TRUEs
plist<-c(plist,(sum(delays<=i)/delayLen))
}
return(plist)
}