Perl: the Markov chain saw | |
PerlMonks |
Re: Curved Random Distributionby blokhead (Monsignor) |
on Oct 18, 2005 at 17:08 UTC ( [id://501067]=note: print w/replies, xml ) | Need Help?? |
The reason it works is because the normal distribution is shaped like exp(-x2). A reasonable first-order approximation of exp(x) is (1+x), so we can try using 1/(1+x2) to approximate the normal curve. This function's integral (accumulating probability distribution) is none other than arctan. This gives you a bell-shaped curve in the shape of 1/(1+x2), which is qualitatively "bell-shaped", but has a lot more probability in its "tails" than the normal distribution. Update: Augh, this is completely backwards, please ignore. In any case, it should be taking tangents of a random angle (or something?), but I can't get the scaling factors to work out right now. So much for a quick and easy alternative. ;) Can someone who actually knows this math say (correctly) what I was trying to say? I want the accumulating probability distribution to be shaped like arctan. Update 2: (trying to salvage this node) After thinking about it for a while, this seems to work (stealing code from BrowserUk's reply): The variance is pretty wide, though ... you might be well-served to scale it down a bit. Although it's nice that the tails do extend really far. blokhead
In Section
Seekers of Perl Wisdom
|
|