4 ms·
Some motivation for the non-math folks out here - twitter shows an ad on your timeline. Assume the chances of twitter getting a callback on that ad is uniform (
by dxbydt 14y ago
Some motivation for the non-math folks out here - twitter shows an ad on your timeline. Assume the chances of twitter getting a callback on that ad is uniform ( very unlikely, but play along ). That means roughly 50% of folks will ignore the ad or dismiss the ad, the rest will actually engage with the ad impression. Lets say twitter makes a dollar per engagement. How many ads need to be shown to make the first dollar ? Two dollars ? How about five, ten, hundred, or a million ?
That's what this problem gets at.And in case you are curious about the solution to all that money -
----
scala> def uniform = util.Random.nextDouble
def sumsTo(n:Int) = {
var (times, sum) = (0.0d,0.0d);
while(sum < n) { sum += uniform; times += 1.0d; };
times
}
def meanSumsTo(n:Int) =
(1 to 1000000).map(_=>sumsTo(n)).sum/1000000.0d
List(1,2,5,10,100,500,1000).map(x=> (x,meanSumsTo(x))
scala> res1: List[(Int, Double)] = List((1,2.718594), (2,4.672438), (5,10.665755), (10,20.668308), (100,200.65537), (500,1000.669558), (1000,2000.669246))
----
So you need to show 3 ads to make a buck, 5 ads to make $2 etc.