What might happen if when using a random number generator, if a particular run is not so random, you "help it out" a little bit? For example, if we use a random number generator to simulate $10,000$ fair coin tosses. Normally we wont get $5,000$ of each possible outcome so there are actually $2$ related questions here:
1) When is the "best" time to force it to "even steven", towards the end of the run or when one outcome strays a set amount away from the other (but with a minimum percentage of flips so we are not correcting super early on like after the 1st, 2nd, 3rd flips.... For example, we can say that maybe after $10$% of the target # of flips (in this case that would be $1000$ flips), perhaps if either heads or tails is more than $510$ ($51$%), we would then force a few more of the other outcome to help balance it out.
2) What might this "correction" do to the "randomness"? Might it introduce some other bias? I assume any bias would be closely related to how and when the correction is made. For example, if we wait until the very end to correct for too may tails, we will artificially introduce a long string of heads so is there any algorithm to do something like this fairly?
You can assume the reason for asking this is I already have a program written that uses the random number generator and I want to instead force it to be $5000$ of each outcome so I am wondering when and how to do that. It is much simpler to just force this than to rewrite the code to solve a problem some other way.
Also I suspect someone will answer something like "just do $100,000$ or even $1,000,000$ coin flips and then you wont have to "help it out". My concern about that is these $10,000$ random numbers are being used in a path walking program which gets slow when more than about $10,000$ flips are used.