# Problem with deriving the cumulative distribution from the density function

Consider the continuous distribution with density function $$p(x) = \frac{1}{2}\cos(x) \;, \quad -\frac{\pi}{2} < x < \frac{\pi}{2}.$$

I want to derive the cumulative distribution function for this density function. In other examples I've seen, this is usually done by taking the anti-derivate of the density function which (in the examples that I've seen) leads to a valid CDF.

However, it seems that following the same approach for this example yields an invalid CDF, $$\begin{cases} \: -0.5 , \quad \quad x \leq \frac{-\pi}{2} \\ \frac{1}{2}\sin(x), \: \: -\frac{\pi}{2} < x < \frac{\pi}{2} \\ \: \: \: 0.5, \quad \quad x \geq \frac{\pi}{2} \end{cases}$$ and that it somehow needs rescaling. What am I doing wrong here, and how does one go about finding the CDF for this density function? • The integral for the CDF of a density $f$ is, generically, $F(x) =\int_{-\infty}^x f(t)\,\mathrm dt.$ Notice the lower limit. You started with a lower limit of $0.$
– whuber
Jun 5 at 13:22

Just add $$C = 0.5$$ and your anti derivative becomes a valid CDF with corresponding density $$p(x)$$.