My professor has given me a random variable $X$ with a probability density function:
$$f(x) = cos(x), 0 ≤ x ≤ π/2.$$
I have to write an acceptance-rejection algorithm to simulate values of $X$ based on a proposal with density:
$$h(x) = kx, −π/4 ≤ x ≤ π/2$$
where $k$ is some fixed value.
As far as I understand, a density function has to be non-negative, and $h(x)=kx$ takes on both negative and positive values over the interval $[−π/4, π/2]$, so I'm struggling to figure out how to solve this.