# Confusion about the probability of a continuous random variable at a given point

A person randomly chooses a battery from a store which has 80 batteries of type A and 260 batteries of type B. Battery life of type A and type B batteries are exponentially distributed with average life of 8.0 years and 13.0 years, respectively. If the chosen battery lasts for 5 years, what is the probability that the battery is of type A?

Define random variable $$X$$ and $$Y$$ such that $$X = \begin{cases} 1, & \text{if the battery if of type A} \\ 0, & \text{if the battery if of type B} \end{cases}$$ $$Y = \text{Lifespan of a battery}$$

In the answer sheet they have used $$f_{Y|X}(y) = \lambda e^{-\lambda y}$$, where they put $$y = 5$$ to get the answer. But I studied that the probability of a continuous random variable at a given point is $$0$$. So I did it like this $$P(X = 1 | Y \ge 5)$$ to find the answer. Why they have done that and what's the correct way to solve this question? I am really confused between these concepts.

• Basically you are asking why $\Pr[Y=5]$ was used even though it is supposed to be $\Pr[Y=5]=0$ owing to it being a continuous rv, aren't you? Commented Jul 11 at 6:03
• The density of $Y$ given $X$ should be $f_{Y|X=x}(y)=xe^{-yx}$ with $X$ being $1/8$ with probability $80/340$ and $1/13$ with probability $260/340$. Commented Jul 11 at 7:40

The question wording leaves a little bit of room for interpretation, but I would assume that they mean that the chosen battery lasts exactly 5 years. Not: after 5 years, it's still going.

If you do as you suggested, and calculate $$p(X=1|Y\geq5)$$, then you condition on the lifespan being greater than or equal to 5 years. But this doesn't make sense if we assume that the lifespan was exactly 5 years. It does of course make sense under the second interpretation that I mentioned, that we know the battery is still alive after 5 years, but we don't yet know when it will fail.

Now, you are correct that the probability of a continuous random variable taking any one specific value is 0. That is why we have to deal with probability densities in this situation, which specify how concentrated the probability is around a given value (more formally, the probability density function is the derivative of the cumulative distribution function, which is valid for continuous variables). So we get: $$p(X=1|Y=5) = \frac{p(Y=5|X=1)p(X=1)}{p(Y=5|X=0)p(X=0)+p(Y=5|X=1)p(X=1)}$$ $$=\frac{\frac{1}{8}e^{-\frac{1}{8}\times5} \times \frac{80}{340}}{\frac{1}{13}e^{-\frac{1}{13}\times5}\times \frac{260}{340} + \frac{1}{8}e^{-\frac{1}{8}\times5} \times \frac{80}{340}}$$ $$=\frac{\frac{1}{8}e^{-\frac{1}{8}\times5} }{\frac{1}{13}e^{-\frac{1}{13}\times5}\times \frac{260}{340} \times \frac{340}{80} + \frac{1}{8}e^{-\frac{1}{8}\times5} }$$ $$=\frac{\frac{1}{8}e^{-\frac{1}{8}\times5} }{\frac{1}{4}e^{-\frac{1}{13}\times5} + \frac{1}{8}e^{-\frac{1}{8}\times5}}$$ $$=\frac{1}{\frac{\frac{1}{4}e^{-\frac{1}{13}\times5}} {\frac{1}{8}e^{-\frac{1}{8}\times5}} +1}$$ $$=\frac{1}{2 e^{-5(\frac{1}{13}-\frac{1}{8})} +1}$$ $$= 1 - 2 e^{-5(\frac{1}{13}-\frac{1}{8})}$$ $$\approx 0.2822$$

• You used the wrong parametrization. $\lambda = 1/\mu$, so you must use $1/8$ and $1/13$! Commented Jul 11 at 10:28
• Ah yes, of course. Sloppy of me - thanks for spotting that! Commented Jul 11 at 11:59

Ruben gave a very good answer with the lifespan of five years, exactly, which seems to be what the people who wrote the question wanted. But .... I think that's kind of a weird way to think of the question. Not weird in terms of learning the stats and the math, but weird on a practical basis.

First, how exactly? Rounded to the year? Day? or what? If we round to anything then we are no longer dealing with exact measure and we no longer have a probability of 0. If this is some sort of common battery situation (like in some household appliance) then I'm guessing we'd be interested in rounding to the year. And if the authors of the question meant some tighter rounding, why say "years"? Why not say "1500 days" or whatever?

Second, who would care about the exact time? Maybe there are some situations, but I think that, in the vast majority of cases, the interest would be in "five years or more", so I would interpret the question as you did.

Ruben and Peter Flom have given the relevant practical answers but I want to point out that conditioning on events with probability 0 is in fact not always a well defined undertaking. If you have no experience with measure theory I'd recommend against looking too much into it. Just using the likelihood should almost always work. Here's Wikipedia if you do want to get into it:

https://en.wikipedia.org/wiki/Conditional_probability#Conditioning_on_an_event_of_probability_zero

This confusion was bothering me every day, so I kept thinking about it and it is today that I really got to understand how they or you found the answer to that. I'm so happy right now.

My approach :

$$P(Y=5|X)$$ is really $$0$$ but still the fraction $$\frac{P(Y=5|X=1)P(X=1)}{P(Y=5|X=0)P(X=0)+P(Y=5|X=1)P(X=1)}$$ is defined. Why? Because the numerator and denominator both are zero which gives an opportunity to perform some calculation on it. And the way I did it is the following:-

$$P(Y=5|X) = \lim_{\epsilon \to 0 } \; P(5-\epsilon where $$\lambda \in \left\{\frac18, \frac{1}{13}\right\}$$. Now substituting this probability back in our fraction with appropriate values we get,

$$P(X=1|Y=5) = \lim_{\epsilon \to 0} \left[\frac{e^{-5/8}(e^{\epsilon/8} - e^{-\epsilon/8})\frac{4}{17}}{e^{-5/8}(e^{\epsilon/8} - e^{-\epsilon/8})\frac{4}{17} + e^{-5/13}(e^{\epsilon/13} - e^{-\epsilon/13})\frac{13}{17}}\right] = \frac00$$ which rings bell for $$\text{L'H\hat{o}pital's}$$ rule. After evaluating the limit you get the desired result as @Ruben got.

• In addition to the above answer, I learned one more thing and that is $f_X(x) \ne P(X=x)$ if $X$ is continuous random variable. If $X$ is discrete then they are equal because they are defined that way. Commented Jul 19 at 13:57
• But then what $f_X(x)$ actually means if $X$ is continuous rv? Commented Jul 19 at 13:58
• > But then what $f_X(x)$ actually means if $X$ is continuous rv? It's a density: en.wikipedia.org/wiki/Probability_density_function Commented Jul 28 at 20:07