Perl Monk, Perl Meditation | |
PerlMonks |
Re: Randomly biased, random numbers.by roboticus (Chancellor) |
on Dec 05, 2013 at 23:11 UTC ( [id://1065862]=note: print w/replies, xml ) | Need Help?? |
I used to use a "density map" generator back in the day. Basically each time you want a random coordinate, you generate the coordinate plus one extra random number. You then check the number against a density function, and if the extra random number is less than the density at that location, you return the coordinates. Otherwise you try again:
So by defining an appropriate density map function, you can create many types of distributions. The disadvantage is that your density map function may reject too many candidates, slowing things down. (The density_broken function, for example, is quite useless in this regard.) The reason that I thought you might like it is this: For testing a project, I would create distinct distributions by simply drawing an image with MSPAINT or similar and loading that into a lookup table and using a function like density_lookup. I don't know your objections to your own suggestion, so I don't know if this one is interesting or not, though. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|