0

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.

  • 1
    Ask your professor -- there's likely a typographical error here. Maybe they mean $h(x) = \alpha+\beta x,$ for instance; or possibly $h(x)=k+x;$ or maybe $k^x,$ or perhaps something else entirely different. – whuber Jan 13 '23 at 13:54
  • 1
    @whuber Ok - I will do when I next see him. Thank you for the comment, it’s good to have someone else confirm that. – kitty123 Jan 13 '23 at 14:04
  • 1
    Also, it makes little sense to simulate from a proposal on a larger support, hence the proposal should be restricted to $(0,\pi/2)$. – Xi'an Jan 13 '23 at 15:29

0 Answers0