Generating values from continuous distribution

There are often better ways to generate random values from specific distributions but the acceptance-rejection method is fairly easy to understand.

  1. Generate random horizontal and vertical positions in the enclosing rectangle. (Each position is found from a rectangularly generated value.)
  2. If this point lies within the target probability density, return its horizontal coordinate x as a value from this distribution. Otherwise, repeat from step 1.

Generate 30 or more values. Their distribution should conform reasonably with the target distribution!