The distribution algorithm for * part * normal distribution

Is there a one-pass algorithm that can generate numbers distributed over part of the normal (Gaussian) distribution?

I want to specify a base value (distribution center), standard deviation, and minimum and maximum values.

For example, I would like all values ​​to be distributed between -0.5 and +1 standard deviations in the same ratio as in the normal distribution (obviously increased to account for missing tails).

Obviously, you can use the loop and only exit if the generated number was between the minimum and maximum, but this can continue for a long time if min / max is too close to each other or too far in the tail.

I am assuming a language with a Gaussian random number function (I use Java, but I can read almost everything).

+3
source share
1 answer

You can calculate erf for a given gauss at the minimum and maximum points of interest, generate a random number (evenly) between these two values ​​and take the opposite erf.

I know that the Apache library has a function erfin Java, see here , but I'm not sure where to point you for the opposite to erf(in the worst case, of course, you could calculate the latter with Newton-Raphson).

( erf Java, ).

+4

Source: https://habr.com/ru/post/1726644/


All Articles