(I have edited this question into a more general form for greater clarity and utility)
This is not a question about how the catch rate is determined, but about how the game determines if a Pokemon is caught after calculating the catch rate. I know about the various formulae that use factors like HP and what type of ball is being used to spit out some catch rate. Let's say it comes out to 10%. When I throw a Poke Ball, how is it determined whether I receive the 10% result, where the Pokemon is successfully caught, or the 90% result, where the Pokemon breaks free?
I assume the game checks an RNG value against the catch rate. I am looking for an answer that describes how the RNG value is generated, how it is checked against the catch rate, and whether the situation can be manipulated for each of the mainline games/generations.