This question and the answer’s source doesn’t have formulas for beyond Gen 4. Does anyone know these formulas? Also, make sure to include the formula for Gen 5 double battles if it’s any different.
This question still doesn't have a formula, but now the answer’s source does.
If your Pokemon is faster or at the same Speed as the wild Pokemon, fleeing will always succeed. Otherwise: This formula applies to every game starting with Black and White. The only place it might not apply is wild double battles, but we don't have a better formula for that.