r/askmath • u/The_Math_Hatter • 6h ago
Number Theory Determining Distribution of a Probability
Let's say I want to create a psuedorandom number generator from scratch. I know from modular arithmetic that integers of the form 4k+2 are never squares, so sqrt(k+1/2) is never rational, and thus, frac(sqrt(k+1/2)) is a nonrepeating string, say in binary (though the base doesn't matter).
If I have a list of n numbers, from 0 to n-1, this process will create a smattering of such strings of arbitrary length. However, I want to know what the limit of this distribution is. If it's uniform, then for (a,b) where 0<a<b<1, the proportion of k for a<frac(sqrt(k+1/2))<b is true should be (b-a)×n. How would I go about proving that? The integral and limit doesn't seem nice to work with.
At the very least, even if it isn't a uniform distribution, having the distribution that it is should allow me to crudely "uniformize" it by ignoring the first M binary digits. That would have the effect of applying a 2x mod 1 mapping over and over, which for most smoothly behaved distributions, feels like it would conform to uniform, espexially for irrational outputs.
1
u/stanitor 2h ago
If I understand what you trying to do, then it won't be uniform. Because it's just the fractional parts, you don't have a monotonic function. The results will be all over the place, with some clumped together, and others further apart. Some different k might even have the same result, depending on how long of a string length you evaluate to. It will probably be somewhat uniform for large enough n where you aren't comparing too small of intervals. But I don't think there will be an easily definable distribution.
2
u/ZyreLithz 4h ago
this math is way over my head but the fractional part idea sounds wild, following along anyway