Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Creates a random number from (-1..1), exclusive, distributed in an inverse-bell-curve fashion. That is, numbers
- * closer to -1 or 1 are exponentially more likely to appear than numbers closer to 0.
- */
- public static double invertedNormalRandom(Random r) {
- /*
- * Implementation note: log10 reaches y=0 at x=1, and reaches y=1 at x=10, so it's really important, if we
- * want to get good numbers out of it, to feed it numbers in the range of 1..10. So we multiply by 9 and add 1.
- */
- double a = Math.log10((r.nextFloat()*9)+1);
- return (r.nextBoolean()) ? a : -a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement