3 ms·
I'm sort of curious how the theory that "1" is most likely to be the first digit of a random number applies to this. Does anyone know or can expand on what I'm
by noduerme 3y ago
I'm sort of curious how the theory that "1" is most likely to be the first digit of a random number applies to this.
Does anyone know or can expand on what I'm talking about?
- thewakalix 3y agoThat's Benford's law, but I don't think it applies here. From Wikipedia: > Benford's Law tends to be most accurate when values are distributed across multiple orders of magnitude, especially if the process generating the numbers is described by a power law (which is common in nature).
- noduerme 3y agoit definitely shows up in 8-bit and 32-bit stuff though, doesn't it? There's just a lot less of those numbers where the leading digit (in decimal) is larger than 3 or so.
- saghm 3y agoAssuming you aren't 0 padding, there are 111 unsigned 8-bit integers beginning with 1 (1, 10-19, and 100-199), 67 beginning with 2 (2, 20-29, and 200-255); all of the other digits appear 11 times (in single-digit form and as the leading digit in the tens place for their "decade") except 0, which appears first only in 0 itself. Unsigned 32-bit integers will have 1, 2, and 3 tied for first with 4 far back in fourth place and 5-9 in even the more distant penultimate position (with 0 still being last). If you're dealing with signed integers, you'll have an even more lopsided distribution in favor of 1 for both 8-bit and 32-bit numbers (assuming you don't count the negative sign). And of course, all of this is assuming base ten; you can make things even more uniform by using binary!
- noduerme 3y agowell yeah, no one would want to argue that a leading '1' wasn't pretty predominant in unpadded binary ;) thank you for the good, concise, starter breakdown of why this is a feature of decimal math.
- immibis 3y agoIt doesn't apply.
- noduerme 3y agoIsn't it a similar observation, though? I've spent a lot of time thinking about random numbers, and how to pull random booleans out of pseudo-random numbers. No one would ever choose UUIDs to serve as a source of randomness. But the observation that "4" comes out really often in UUIDs is on par with the observation that you can't just take the first digit of a 32-bit unsigned, un-padded random number and expect it to be an equally weighted random between 1 and 9. Right? So doesn't that relate?
- cowsandmilk 3y agoNo it isn’t. This is that the standard says you will always have 4 in this position. Distribution of randomness has no involvement.
- noduerme 3y agooh. So if you always know there's a 4 there and then you can trigger infinite recursion based on that... what's the big insight here?
- phaker 3y agoThis depends on the distribution, for a uniform distribution all 16 hex digits are equally likely in every position. Also for benford's law to show up you want your data to span several orders of magnitude (so e.g. you have numbers in tens, hundreds and thousands) and for a datapoint to be about as likely to give an n-digit number as a n+1-digit number, not everywhere and not exactly but it needs to dominate over there being ten times times as many of them with each step.
- kevincox 3y agoI believe that that theory is about un-padded numbers. It doesn't apply to fixed-length numbers generated in the full range. Because 010 would have a leading 0 rather than a leading 1. Since the first byte of a UUID is random and can be any of the allowed values it has no bias in the first digit.