# How to calculate the median of a pdf

I'm new to statistics and I'm struggling to solve a question from an assignment. I have a probability density function and I need to calculate its median

Here is the function:

$$f(x) = 2xe^{-x^2}, x>= 0$$

The answer is $\sqrt{\log 2}$.

Can someone help? I'm trying to learn

• $f$ obviously is not a PDF, because it takes on negative values when $x$ is negative. It is probably intended that $f(x)=0$ when $x\le 0$, but--especially for solving problems that involve computing with PDFs--it is crucial that you specify this explicitly.
– whuber
Commented Mar 20, 2016 at 23:22
• What is the definition of median? Start from there. Commented Mar 20, 2016 at 23:22
• You're right whuber, I re-read my assignment and edited the question. $f(x)$ is 0 when x < 0 Commented Mar 20, 2016 at 23:26

A median by definition is a real number $m$ that satisfies $$P(X\leq m)=\frac{1}{2}.$$ So in your case, we have $$\int_0^m2xe^{-x^2}\,dx=\frac{1}{2}.$$ How do you solve for $m$ then? Hint: integration by substitution.