# How does probability density function work?

Hello. I inserted an image because it's easier to understand my questions.

I don't understand how pdf works. If I say I want te probability of X=1, it returns me 0,667. But what's that? Is it the whole area under the triangle of base 1 and height 0,667? So why doesn't A=b*h/2 equal to 0,667? A=2/6=1/3 ;

Also, if I do the integral of the function (2/3)*x shouldn't it give me the same result as f(1) = 2/3 ? Since the fdp says that the area below the graph is the probability of X=k..

Lets say my random variable is the kilograms of rice that people buy in a store. The probability o X=1 kilogram is zero, because the area under the graph is zero. So it makes more sense to say we want P(0

• By definition, $\mathbb{P}[a\leq X\leq b]=\int_a^bf_X(u)\,du$. In your case, $\mathbb{P}[X=1]=0$ because $X$ is a continuous random variable, i.e. $\mathbb{P}[X=1]=\mathbb{P}[1\leq X\leq 1]=\int_1^1f_X(u)\,du=0$. The key point is that there is a difference between $\mathbb{P}[X=c]$ and $f_X(c)$. The former is always zero when $X$ is a continuous random variable; the latter need not be zero (but could be). The function $f_X(u)$ is a probability density, not a probability. – symplectomorphic Apr 3 '17 at 0:57
• The intuitive idea is that $f_X(x) \Delta x$ tells you (approximately) the probability that $X$ is in the range $[x,x+\Delta x]$. (Here $\Delta x$ is a tiny positive number. The approximation is good when $\Delta x$ is very small.) – littleO Apr 3 '17 at 1:15

In this example, you can think of the area under the PDF between two limits (say, between $1$ and $3$) as the probability that the random variable falls between those two limits. Here, a triangle of base $2$ and height $\frac23$ yields an area, and thus a probability, of $\frac23$.

More generally, the height of the PDF represents a kind of probability rate: the variable falls within an infinitesimal range around $1$ of width $dx$ with an infinitesimal probability of $\frac23 dx$. Around $2$, where the height of the PDF is $\frac13$, the rate is $\frac13 dx$ per $dx$ width of interval. And so on. That is why the integral of the PDF produces a probability. Note that this means the integral (and therefore the area) over the entire domain of the random variable must be $1$—the probabilities of all possibilities add up to $1$, in other words.

• Why does it has to do with limits? Like P(a<X<b). And what would mean f(1)? Is it only to know the image on y axis? – Vitor Aguiar Apr 3 '17 at 1:39

The probability that the random variable is between two numbers on the $x$-axis is the area under the graph of the density function above the part of the $x$-axis that is between those numbers. For example, look at the part of the graph between $x=2$ and $x=3.$ The area under the graph between those points is a triangle whose base has length $1$ and whose height is $1/3$, so whose area is $1/6.$ Thus the probability that the random variable is between $2$ and $3$ is $1/6.$

• Yes, but what does it mean f(1) =? – Vitor Aguiar Apr 3 '17 at 1:36
• The fact that $f(1)=2/3$ means for small intervals centered at $1$, the probability that the random variable is in the interval can be made as close as desired to $2/3$ the length of the interval, by making the interval short enough. – Michael Hardy Apr 3 '17 at 2:02

For a "continuous" (non-discrete) random variable the probability for any individual outcome is zero. The pdf does not represent probabilities, it is a non-negative function that integrates to $1$ in it domain, that is

$$\int_{-\infty}^\infty f_X(x)\mathrm dx=1$$

For a continuous random variable their probabilities are determined by areas under it pdf... by example

$$\Pr[0\le X\le 1]=\int_0^1f_X(x)\mathrm dx =\frac{x^2}3\bigg|_0^1=\frac13$$

or

$$\Pr[X\ge 1/2]=\int_{1/2}^\infty f(x)\mathrm dx=\int_{1/2}^1\frac{2x}3\mathrm dx+\int_1^3\left(1-\frac{x}3\right)\mathrm dx=\frac{x^2}3\bigg|_{1/2}^1+\left(x-\frac{x^2}6\right)\bigg|_1^3=\\=\frac13-\frac1{12}+\left(3-\frac32\right)-\left(1-\frac16\right)=\frac3{12}+\frac32-\frac56=\frac{11}{12}$$

obviously we have that $\Pr[X\le1/2]=1/12$. In the same way for any individual $x=a$ we have that

$$\Pr[X=a]=\int_a^a f_X(x)\mathrm dx=0$$

• If I say I want the probability of X=1, it would be zero, as you said. I understand. It is right to say P(0<X<1)... so what does means f(1) = 2/3 ? – Vitor Aguiar Apr 3 '17 at 1:16
• to be honest, I dont know it meaning Vitor. I read somewhere that it represent the "density" of the random variable at this point, by analogy with the physical concept of density, but I dont remember something more. If we have a physical analogy with pressure then the pressure in an infinitesimal point is zero but in some area it can have some positive value. Probably is the same idea here. – Masacroso Apr 3 '17 at 1:19
• @VitorAguiar $f(1)=2/3$ basically means that $\lim_{\Delta x \to 0^+} \frac{P(X \in [1-\Delta x,1+\Delta x])}{2\Delta x}=2/3$. This division by $2\Delta x$ is why a pdf measures density (probability per length) rather than mass (probability, period). A caveat is that this may not be true at a point where $f$ is not continuous (for example, at $x=0$ for the exponential distribution). – Ian Apr 3 '17 at 1:33
• @Ian could you answer it on an answer, to understand the code? – Vitor Aguiar Apr 3 '17 at 1:46