Skip to content

Instantly share code, notes, and snippets.

@drsnyder
Created October 30, 2013 23:30
Show Gist options
  • Save drsnyder/7242091 to your computer and use it in GitHub Desktop.
Save drsnyder/7242091 to your computer and use it in GitHub Desktop.
Click rate estimation.
# Aapproximation for the 95th % of clicks per minute given a 25k click rate per
# day from viglink.
# Assumes that the click rate follows an exponential distribution where
# the per-unit time we are using is 1min.
viglink.clickrate = 25000 # day
rate.min.u = viglink.clickrate/24/60 # min
print("rate per minute")
rate.min.u
# mean of exponential distribution is u = 1/lambda, lambda = 1/u
rate.param = 1/rate.min.u
# take a sample
ctr.sample = rexp(1e6,rate.param)
# what does the distribution look like?
print("summary of sample")
summary(ctr.sample)
sample.means = replicate(100, {
ctr.sample = rexp(1e6,rate.param)
# take the 95th %
sort(ctr.sample)[as.integer(length(ctr.sample)*0.95)]
})
summary(sample.means)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment