Interview Question

Data Scientist Interview

-Menlo Park, CA

Meta

We have two options for serving ads within Newsfeed: 1 - out of every 25 stories, one will be an ad 2 - every story has a 4% chance of being an ad For each option, what is the expected number of ads shown in 100 news stories? If we go with option 2, what is the chance a user will be shown only a single ad in 100 stories? What about no ads at all?

Tags:fb_prob
AnswerAdd Tags

Interview Answers

16 Answers

10

For the questions 1: I think both options have the same expected value of 4 For the question 2: Use binomial distribution function. So basically, for one case to happen, you will use this function p(one case) = (0.96)^99*(0.04)^1 In total, there are 100 positions for the ad. 100 * p(one case) = 7.03%

rh on

11

For "MockInterview dot co": The binomial part is correct but you argue that the expected value for option 2 is not 4 but this is false. In both cases E(x) = np = 100*(4/100) = 4 and E(x) = np=100*(1/25) = 4 again.

Josito on

7

Chance of getting exactly one add is ~7% As the formula is (NK) (0,04)^K * (0,96)^(N−K) where the first (NK) is the combination number N over K

Filip on

8

Bin(100, 0.04,1) Bin(100, 0.04, 0) Bin(n,p,r) = Binomial distribution for n trials, p probability of being ad and r number of ads.

Chaiwala on

3

1. Calculate the probability of getting 1 ad and 99 no ads = (.04)^1 * (.96)^99 2. Calculate the number of combinations where order does not matter (meaning you can be served an ad on the 25th story or 1st story -- it does not matter) = 100! / (99!*1!) = 100 multiple 1 * 2 which gives you 7% of being served an ad.

Anonymous on

2

1) What is the Expected count of ads per 100 stories? For mode 1 the probability of 4 ads is 1, and all other counts is zero. The expected value is 4. For mode 2: The count of successes in n independent trials of probability p is distributed Binomial(n,p). The expected value of Binomial(n,p) is np. The expected value of mode 2 is also 4. This matches our intuition. 2) What is the probability of just one ad in a sequence of 100? We will consider only mode 2 (since mode 1 is obviously zero). This is equivalent to the probability of just one success in a sequence of 100 Bernoulli trials with probability .04. Again, the count of successes is distributed B(100, .04). Let us consider the PMF of Bernouli: (nCk) p^k q^(n-k) , where k is the count of successes. Substituting we have (100c1) .04^1 * .96^99 = .0702... Finally, let us consider the case where k = 0. Substituting the pmf again, we find p(k=0) ~= .0168...

Anonymous on

0

Given: Case 1 : P(ad) = 1/25 = 0.04 Case 2: P(ad) = 0.04 Q1: Expected number of Ads in 100 stories = 100 * P(ad). Case 1: (1/25)*100 = 4 Case 2: (0.04)*100 = 4 Q2. Chance a user will be shown only a single ad in 100 news stories: P(X=1) = (100)*(0.04)*(0.96)^99 = 0.07 ~ 7% P(X=0) = (0.96^100) ~ 1.7%

Anonymous on

0

Can someone explain why the answer for part 2 is not 4? What is the evidence that we should use binomial?

Goosal on

0

For each option, what is the expected mean and variance a user will be shown 2 back-to-back ads?

NAYEON on

0

4. My question is does the 4 ads pay for the cost 100 news feeds?

Anonymous on

0

for the follow up: p = 0.04 1-p = 0.96 Ho: p=0.04 Ha: p<0.04 z_stat = 0.01-0.04/np.sqrt((0.04*0.96)/100)=-1.5 A whole lot of chance for 1 in 100 stories to happen.. cannot reject the null.

Anonymous on

0

what is the expected mean and standard deviation to have back to back ads in those two method?

Anonymous on

7

Expected number of ads in option 1 is 4. Expected number of ads in option 2 is 0.04 * 100, which is also 4.

Anonymous on

0

Thanks Josito! you are right -- 4 is the asnwer, sorry for the confusion!

MockInterview dot co on

2

Most of the answers are wrong for option #2. The expected value for option # is NOT 4 ads! you should rather create a probability distribution. P(ads = 0) = 1.69% P(ads = 1) = 7.03% P (ads = 2) = 14.5% P(ads = 3) = 19.73% P (ads = 4) = 19.94% P(ads = 5) = 15.95% .... Most of the P (ads >= 9) = ~0% and the total should add upto 100% And if you are struggling about why that's the case then you should google "binomial distribution". We have similar questions on MockInterview(dot)co if you want to practice.

MockInterview dot co on

1

For chance of getting one add is ~1.4%

Anonymous on

Add Answers or Comments

To comment on this, Sign In or Sign Up.