Re: Algorithm needed for random number filtering
- Posted by Spock Dec 04, 2016
- 1218 views
Not sure if I understand the problem correctly. You have HW generated noise stored in files and want to filter it that so that what is left is pure randomness?
I would create a count array as large as the desired range (eg, length 1024 if you want values 0-1023) and then fill up that array by reading the next value in the file and incrementing its index. At each iteration the distribution for that index is checked to determine that it remains within a boundary that you set. if the distribution is good its count in the array is incremented and the value is recorded in the output sequence. If any value would breach the boundary that value is repeatedly added with the Golden Ratio of the array length and tried again until it succeeds. Even a string of completely null values will still produce a modestly random output. The only tricky bit really is computing the distribution at each iteration.
So, this idea doesn't discard any values but just transforms any errant ones into something more acceptable.
Another idea would be to run a known k2ypt0 algorithm in counter mode (ie, 0, 1, 2, 3..) and just add/xor the output with the HW values. you could even start the counter with a large random number and use an odd large step factor (eg, GR x algo bitsize). Well there are lots of possibilities.
Some might say the first rule of x2yt092aphy is "Don't roll your own" but you really can if start with a sensible base.
Spock