Search code examples
sqloracle-databaserandomplsqlnormal-distribution

Normal distribution in Oracle


I would like to generate a normal distribution in PL/SQL - Oracle. I know that we can generate this kind of distribution via dbms_random but I would like to specify the paremeters of the normal function (interval, mean, standard deviation).

Is there an easy way to generate this distribution or should I code my own function?

Thanks


Solution

  • If you want to generate numbers from an arbitrary normal distribution, there are only two parameters that make sense, the mean and the standard deviation. I'm not sure what "interval" you'd want to specify unless you want to produce a truncated distribution.

    Given a number from a standard normal distribution (mean 0, standard deviation 1 which is what dbms_random.normal returns), it's pretty trivial to convert it to an arbitrary normal distribution. Just multiply by the standard deviation you want and add the mean that you want. If you want to then make the distribution non-normal by truncating particularly high or low values, you can do that as well.