Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. /**
  2. * Creates a random number from (-1..1), exclusive, distributed in an inverse-bell-curve fashion. That is, numbers
  3. * closer to -1 or 1 are exponentially more likely to appear than numbers closer to 0.
  4. */
  5. public static double invertedNormalRandom(Random r) {
  6. /*
  7. * Implementation note: log10 reaches y=0 at x=1, and reaches y=1 at x=10, so it's really important, if we
  8. * 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.
  9. */
  10. double a = Math.log10((r.nextFloat()*9)+1);
  11.  
  12. return (r.nextBoolean()) ? a : -a;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement