java-faker icon indicating copy to clipboard operation
java-faker copied to clipboard

Bias to smaller numbers

Open AlexRFox opened this issue 2 years ago • 1 comments

I'm not sure if this is intentional or not, so I'm not sure if this should be documented or fixed. I believe this function creates a bias to smaller numbers, because it has a 1/9 chance to pick lengths from 1 to 9 inclusively, then it generates a random number from 0 to 10^(randomly picked size). So there's a 1/9 chance it'll pick a length of 1, then a 1/10 chance it'll pick a 0, leading to a 1/90 chance to pick 0 in a range that goes from 0 to 10^9.

https://github.com/DiUS/java-faker/blob/a8b8ff0acc6fcc629d08a3a9952f83be56a9a3c3/src/main/java/com/github/javafaker/Number.java#L68

AlexRFox avatar Jan 24 '23 19:01 AlexRFox

Alex, this library is no longer maintained. Have a look at www.datafaker.net for a drop-in replacement

bodiam avatar Jan 24 '23 21:01 bodiam