I have a problem with computing the value of constant $C$ and quartile Q2.
The task is that feature X has a density $f(x)$, $f(x) = -\infty < x < \infty$ , defined as:
$$f(x) = \left\{ \begin{array}{ccc} x^3-x & \mbox{if} & x \in [-1,0] \\ C\cos(2x) & \mbox{if} & x \in [0,\pi/4] \\ 0 & & \mbox{otherwise} \end{array}\right.$$
How should I do this?
Thank you in advance.
You need that $f(x) \geq 0$ for all $x$ (which is true as long as $C \geq 0$). Next, you need $\int_{-\infty}^{\infty} f(x)\,dx=1$.
Clearly, $$\int_{-\infty}^{\infty} f(x)\,dx= \int_{-1}^0 (x^3-x)\,dx + \int_0^{\pi/4} C\cos(2x)\,dx$$
Compute the integral from $-1$ to $0$ and then the integral from $0$ to $\pi/4$. Add them together, set equal to $1$, and solve for $C$.