What's the name of this random number generation algorithm? I'm looking for the name of an RNG method or algorithm, described below. Combining multiple results of a non-uniform random number generator can produce a more uniform result. It seems like this would be a common method employed by RNG algorithms, and especially HRNGs, to produce more statistically random results.
It would be awesome if someone could help identify the math/stat/crypto name for this method
The code below demonstrates a simple implementation of this method, with the 'bad' RNG producing non-uniform results, and the 'good' RNG producing about 50/50 results.
import random

# Function representing a non-uniform random number generator
def bad_RNG():

    result = 0
    if (random.random() &gt; .99):
        result = 1

    return result

# Function that repeatedly applies an RNG function to create a more uniform result
def good_RNG():

    result = 0
    for i in range(100):
        if (bad_RNG() != bad_RNG()):
            result = 1 - result

    return result

# Tests RNG functions by running them 100 times, and printing the distribution of their results
def test_RNG(RNG_func):

    zeros = 0
    ones = 0
    
    for i in range(100):

        result = RNG_func()

        if (0 == result):
            zeros = zeros + 1
        else:
            ones = ones + 1

    print(zeros, end=&quot;|&quot;)
    print(ones)

print(&quot;bad_RNG result:&quot;)
test_RNG(bad_RNG)
print(&quot;\ngood_RNG result:&quot;)
test_RNG(good_RNG)

Alternative English Explanation
Assume an RNG function F() that returns either 0 or 1. F() results are non-uniform, as it usually returns a 0. By summing several F() results, and applying modulus 2, the result approaches a 50/50 uniform distribution.
The algorithm described is an unbiasing algorithm, which is a type of randomness extraction algorithm.
Another method is von Neumann unbiasing where you
can take 2 bits $(X_n,X_{n+1})$ and output $Z=0$ if
$(X_n,X_{n+1})=(0,1),$ output $Z=1,$ if
$(X_n,X_{n+1})=(1,0),$ and discard the two
bits otherwise. This gives exactly uniform
output bits, if the sequence $X_n$ is independent and identically distributed since both the above $(0,1),(1,0)$ have probability exactly $p(1-p)$.