Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

Question

A commuter takes one trip to work and one trip home. The probability of using Lyft to work is pp, where 0≤p<1/30\le p<1/3. If the commuter uses Lyft to work, the probability of also using it home is 2p2p. Otherwise, the probability of using it home is pp.

Find:

  1. The unconditional probability of using Lyft home.
  2. The expected number of Lyft trips per day.
  3. The probability the commuter used Lyft to work given that they used it home.

For the third part, identify any value of pp for which the conditioning event has probability zero.

Hint 1

Split the home trip by whether the work trip used Lyft. The two cases do not overlap and cover every day.

Hint 2

For the expected count, add one indicator per trip. For the last part, divide the probability of both Lyft trips by the probability of a Lyft trip home.

How to Answer in the Interview

A phone-screen warm-up with three short asks. Each one tests a single rule: total probability, linearity of expectation, and Bayes' rule. The points go to naming the events, keeping the direction of conditioning straight, and catching the p=0p=0 edge case.

Clarify first:

  • "Is the 2p2p for the home trip conditional on a Lyft trip to work, or is it the overall chance of a Lyft trip home?" This post reads it as conditional, as the prompt states. If 2p2p were unconditional, part 1 would be given outright, and part 3 would need the joint probability of both trips, which the prompt would then not supply.
  • "Is p=0p=0 allowed?" It is, and part 3 is undefined there.

TIP

How I'd say it in the interview: "I split on the work trip. Lyft home has probability p⋅2p+(1−p)⋅p=p+p2p\cdot2p+(1-p)\cdot p=p+p^2. Expected trips is P(W)+P(H)=2p+p2P(W)+P(H)=2p+p^2, no independence needed. Then Bayes gives P(W∣H)=2p2/(p+p2)=2p/(1+p)P(W\mid H)=2p^2/(p+p^2)=2p/(1+p), defined only for p>0p>0."

Then walk through:

  1. Define WW and HH and read the given numbers as P(W)P(W), P(H∣W)P(H\mid W) and P(H∣Wc)P(H\mid W^c).
  2. Get P(H)P(H) by weighting each case. Most candidates lose points here by averaging 2p2p and pp equally.
  3. Add the two indicator expectations for the trip count.
  4. Divide the joint probability by P(H)P(H), then state the p=0p=0 case.

Solution

Let WW be the event "uses Lyft to work" and HH the event "uses Lyft home". The answers are P(H)=p+p2P(H)=p+p^2, an expected 2p+p22p+p^2 Lyft trips per day, and

P(W∣H)=2p1+pfor 0<p<1/3.P(W\mid H)=\frac{2p}{1+p}\qquad\text{for }0<p<1/3.

When p=0p=0, the first two answers are 00 and the third is undefined, because the commuter never takes Lyft home.

Part 1: weight each case by how often it happens

The prompt gives the home probability only inside each case, so split every day by the work trip. The cases WW and WcW^c are disjoint and cover every day, which lets their contributions add. That is the law of total probability:

P(H)=P(W) P(H∣W)+P(Wc) P(H∣Wc)=p⋅2p+(1−p)⋅p.P(H)=P(W)\,P(H\mid W)+P(W^c)\,P(H\mid W^c)=p\cdot2p+(1-p)\cdot p.

Two paths split on the work trip. Lyft to work (probability p) then Lyft home (2p) gives joint 2p squared. No Lyft to work (1-p) then Lyft home (p) gives p(1-p). Adding gives P(H)=p+p squared.

Expanding, 2p2+p−p2=p+p22p^2+p-p^2=p+p^2. The weights pp and 1−p1-p are the case probabilities, not 1/21/2 each. Check with p=1/5p=1/5: 2/25+4/25=6/252/25+4/25=6/25.

Part 2: add one indicator per trip

Write the daily count as T=IW+IHT=I_W+I_H, where an indicator is 11 when its event happens and 00 otherwise. An indicator's expectation is 1⋅P(event)+0=P(event)1\cdot P(\text{event})+0=P(\text{event}). Linearity of expectation adds means of any random variables, dependent or not, so

E[T]=P(W)+P(H)=p+(p+p2)=2p+p2.E[T]=P(W)+P(H)=p+(p+p^2)=2p+p^2.

With p=1/5p=1/5, that is 5/25+6/25=11/255/25+6/25=11/25.

Part 3: reverse the conditioning

The prompt gives P(H∣W)P(H\mid W). Part 3 asks for P(W∣H)P(W\mid H), the share of Lyft-home days that also had a Lyft trip to work. By the definition of conditional probability, that is the joint probability over P(H)P(H). The joint is the first path from Part 1, P(W∩H)=P(W)P(H∣W)=2p2P(W\cap H)=P(W)P(H\mid W)=2p^2.

P(W given H) equals P(W and H) over P(H), which is 2p squared over (p+p squared), simplifying to 2p/(1+p). The answer requires p greater than 0.

Cancelling one pp from 2p2/(p+p2)=2p2/[p(1+p)]2p^2/(p+p^2)=2p^2/[p(1+p)] gives 2p/(1+p)2p/(1+p). The cancellation needs p>0p>0, which is also exactly when P(H)>0P(H)>0. With p=1/5p=1/5, the result is (2/5)/(6/5)=1/3(2/5)/(6/5)=1/3. Seeing a Lyft trip home raises the chance of a Lyft trip to work from 1/51/5 to 1/31/3.

WARNING

At p=0p=0, the simplified 2p/(1+p)2p/(1+p) returns 00, but the original ratio is 0/00/0. Conditioning on an event of probability zero is undefined, so say so instead of reporting 00.

Code

An exact check with fractions: the case-by-case computation should match the three closed forms for several values of pp.

from fractions import Fraction

for p in (Fraction(1, 10), Fraction(1, 5), Fraction(3, 10)):
    both = p * (2 * p)
    home = both + (1 - p) * p
    trips = p + home
    work_given_home = both / home

    match = (home == p + p**2 and trips == 2*p + p**2
             and work_given_home == 2*p / (1 + p))
    print(f"p={p}: P(H)={home}, E[T]={trips}, "
          f"P(W|H)={work_given_home}, closed forms match: {match}")

Output:

p=1/10: P(H)=11/100, E[T]=21/100, P(W|H)=2/11, closed forms match: True
p=1/5: P(H)=6/25, E[T]=11/25, P(W|H)=1/3, closed forms match: True
p=3/10: P(H)=39/100, E[T]=69/100, P(W|H)=6/13, closed forms match: True

Additional Notes

Common mistakes

  • Averaging the two home probabilities equally, (2p+p)/2=3p/2(2p+p)/2=3p/2. It uses both given numbers but treats the two cases as equally frequent. At p=1/5p=1/5 it gives 3/103/10 instead of 6/256/25.
  • Reversing a conditional by swapping labels. P(H∣W)=2pP(H\mid W)=2p is 2/52/5 at p=1/5p=1/5, while P(W∣H)=1/3P(W\mid H)=1/3.
  • Multiplying the marginals for the joint probability. The trips are dependent, so P(W)P(H)=6/125P(W)P(H)=6/125 at p=1/5p=1/5 is wrong. The joint is P(W)P(H∣W)=2/25P(W)P(H\mid W)=2/25.
  • Assuming linearity of expectation needs independence. It does not.

What this question tests

The question tests the three basic rules of conditional probability and whether you apply them in the right direction. The interviewer looks for clearly named events and a stated edge case. Likely follow-ups:

  • Exactly one Lyft trip: p(1−2p)+(1−p)p=2p−3p2p(1-2p)+(1-p)p=2p-3p^2, which is 7/257/25 at p=1/5p=1/5.
  • Are the trips independent? No, because P(H∣W)=2p≠p+p2=P(H)P(H\mid W)=2p\ne p+p^2=P(H) whenever 0<p<10<p<1.
  • Expected Lyft trips over a five-day week: 5(2p+p2)5(2p+p^2) by linearity, with no assumption about how days relate.

Patterns to reuse

  • When a probability is only given inside cases, split on the event that defines the cases and weight each case by its own probability.
  • Bayes' rule is a joint over a marginal, and the marginal usually comes from total probability over the same split.
  • Turn any count into a sum of indicators before taking its expectation.
Your progressLogin to save progress
Spot an issue or have a suggestion?