I have been studying probability and statistics. I am confronting an issue of being persuaded of "Why do we declare a density function to be zero when it is out of a range of the density variable?" My sense says that It should not exist(But not existing with a value that is zero). For example, assume the following density
$$f(x) = cx^2 \texttt{ for }0 \leq x \leq 1, f(x)= 0\texttt{ otherwise.}$$
Actually, in the otherwise part, density won't exist since the variable $x$ is not taking the value outside that range. More explanation, I feel that zero is a value rather than taking it representing the " does not exist " situation. Is anyone here has a better intuition, so that he can persuade me?
Thanks in advance.
One of the useful things you can do with a density is to compute the probability that the observed value of a random variable is within a certain interval. For example, if the random variable $X$ has density function $f,$ then $$ P(a \leq X \leq b) = \int_a^b f(x)\,dx. $$
Now consider a variable with a probability distribution such as the one described in the question, which can take values only within the interval $[0,1].$ That is, by definition $0 \leq X \leq 1.$ Using the standard definition of a probability density function, which sets the density of this distribution to $f(x) = 0$ for $x < 0$ or $x > 1,$ we can still compute the probability that $X$ is in any interval using the same formula: $$ P(a \leq X \leq b) = \int_a^b f(x)\,dx. $$
But if $f$ is not defined outside $[0,1]$ you cannot compute $P\left(-1 \leq X \leq \frac12\right)$ in this way, because you cannot integrate $f$ over the entire interval $\left[-1,\frac12\right].$ Instead you will have to consider various special cases depending on which of the intervals $(-\infty,0),$ $[0,1],$ or $(1,\infty)$ each of the bounds $a$ and $b$ falls within.
It is even worse if you have a variable that can take values only in the set $[0,1] \cup [4,7] \cup [119,125].$ Now if $f$ is not defined outside that set, you may have to take a sum of up to three separate integrals in order to compute $P(a \leq X \leq b),$ with many special cases depending on where $a$ and $b$ fall within, between, or outside the intervals on which $f$ is defined.
On the other hand, the definition of a variable's distribution function is not the definition of the variable. The function is merely a function. The definition of the the distribution function $f$ of a variable $X$ does imply that if $\int_a^b f(x)\,dx > 0,$ then it must be possible for $X$ to take a value in the interval $[a,b].$ But if $\int_a^b f(x)\,dx = 0,$ the distribution function says nothing about whether it is possible for $X$ to have a value in $[a,b].$ You can perfectly well define a variable $X$ with distribution function $f$ that cannot take values within such an interval.