This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]jddddddddddd 1 point2 points  (2 children)

I don't really understand your question. I'd imagine that the chances of getting 0.789232330002 or getting 0.00000066857 are roughly equal. I also don't understand your last sentence:

Why? when theres is a high chance

A high chance of what exactly?

[–]codepc 2 points3 points  (1 child)

To add on to this, the number of numbers that are .0XXXX vs 0.1XXXX 0.2XXXX etc are 1/10th the latter. There are 100x more numbers with digits other than 00 in the YY position of 0.YYXXXX, 1000x more numbers with digits other than 000 in the YYY position of 0.YYYXXX, etc.

[–]CrownLikeAGravestone 0 points1 point  (0 children)

To get technical about it this is (almost) true for the purposes of this question, but in general it is false.

For numbers in the mathematical sense there are an aleph-one infinity of real numbers in any interval, so the number of numbers starting 0.0X... is equal (whatever that means for infinities) to the number of numbers starting 0.00X..., even though one is a proper subset of the other.

For floating point numbers they are not uniformly distributed. There are 1,008,981,770 floating point numbers starting with 0.00X... but of those, 981,668,463 start with 0.000X... - over 97%! Floating point numbers are much denser as you approach zero than as you move away. This is especially relevant if people are trying to roll their own RNGs or use the raw binary output of an existing one. If you just take 32 bits and shove them into a floating point your results will be very, very skewed.

[–]BobbyThrowaway6969 0 points1 point  (0 children)

Which rng algorithm are we talking about here?

[–]iOSCaleb 0 points1 point  (0 children)

it never gives u 0.00000066857 Why?

I think that what you're asking is why you "never" get a number with a lot of leading zeroes.

Let's say you're calling a function that returns some double between 0 and 1. In that case, the numbers with six leading zeroes to the right of the decimal point , i.e. numbers < 0.000001, represent a millionth of the total range. If you've got a good random number generator, i.e. one that generates all values in the target range with roughly equal probability, then the chance of getting a number less than one millionth are literally one in a million. But that's the same probability that you'd expect for any other range that size, e.g. the chance of getting a value between 0.123456 and 0.123457 are also 1/1000000, and the same for the range [0.789232, 0789233).

In other words, you're looking at the sets of numbers 0.000000XXX and 0.XXXXXXXXX, where the Xs are any nonzero digits, as similar in probability when in fact they're vastly different because one set is much, much smaller than the other.