English 中文(简体)
Algorithm to distribute over *part* of a Normal distribution
原标题:

Is there a single pass algorithm that can produce numbers distributed over part of a normal (Gaussian) distribution?

I want to specify a base value (the center of the distribution), a standard deviation, and a min and max values.

For example I might want all values to be distributed between -0.5 and +1 standard deviations in the same ratio as would be found in a normal distribution (obviously increased to take into account the missing tails).

Obviously one can use a loop and only exit if the generated number was between the minimum and maximum, but that could go on for a long time if min/max are too close together or too far out along a tail.

I m assuming a language with a Gaussian random number function (I m using Java, but can read almost anything).

最佳回答

You can compute erf for the given Gaussian at the minimum and maximum points of interest, generate the random number (uniformly) between those two values, and take inverse erf.

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

(I found an algorithm for inverse erf here, with Java implementation, but can t vouch for its quality).

问题回答

暂无回答




相关问题
Algorithm to distribute over *part* of a Normal distribution

Is there a single pass algorithm that can produce numbers distributed over part of a normal (Gaussian) distribution? I want to specify a base value (the center of the distribution), a standard ...

XNA game distribution questions

I want to start on a 2D game using C#, so I m checking out my options. XNA sounds good, but a few points are not very clear to me. If I use XNA, can I just build my game and distribute my game as a ...

How to use Git as content distribution network

The book Git Internal mentions about using git as peer to peer content distribution network at p50, but doesn t have much detail. Especially how to have several branches which has tracking different ...

Weird PyPI authentication behavior

I m trying to upload my package to PyPI. It asks me to identify, I do, it gives an OK response (which doesn t happen unless the identification is right), but then it claims I didn t identify! Why? [.....

热门标签