let $f(x)=(3(x+x^2))/14$ and $x$ between $0$ and $2$ , zero otherwise be the pdf for a random variable $X$ ,Find the median and the mode? let f(x)=(3(x+x^2))/14 and x between 0 and 2  ,
zero otherwise be the pdf for a random variable X
Find the median and the mode
`
Could you please help me Is it correct or not?
 A: If $f(x)$ represents a legal probability density function (which you should check based on the support of the distribution), then for the median we find an $m$ such that
$$\int_0^m f(x) dx = \frac{1}{2}$$
$$\iff \int_0^m (3(x+x^2))/14 dx = \frac{1}{2}$$
$$\iff \frac{3}{14}\int_0^m x+x^2 dx = \frac{1}{2}$$
$$\iff \int_0^m x+x^2 dx = \int_0^m x+x^2 dx = \frac{7}{3}$$
$$\iff \frac{1}{2}x^2 + \frac{1}{3}x^3 \mid_0^m = \frac{7}{3}$$
$$\iff \frac{1}{2}m^2 + \frac{1}{3}m^3 = \frac{7}{3} \iff \frac{3m^2+2m^3}{6} = \frac{7}{3} \iff 3m^2 + 2m^3 = 14.$$
You can show through some algebraic manipulation that $m \approx 1.522.$
As you stated before, we are trying to find
$$\arg\max_x f(x)$$
over $0 < x < 2.$
If we set
$$f'(x) = 0 \implies \frac{3}{14}(1 + 2x) = 0 \implies 1 + 2x = 0 \implies x = \frac{-1}{2},$$
which would not be correct for $0 < x < 2.$ In since if $x \geq 0$, $\frac{3}{14}(x+x^2)$ is monotonically  increasing, and thus the maximum value would be hit at $x = 2$. Hence, the mode is $x = 2$, if $2$ is within the support of the pdf. Otherwise, this function would not have a global maximum (and thus no mode).
