Extract a random number between 0...100 or if you prefer 0...1 .
Then check to see if this number is greater than 75. If this happens, the attacker will win.
$p = rand(0,99); if ($p<75) // Attacker Won!
This has a very simple probabilistic interpretation. if you randomly extract a number between 0...100 , you have a 75% chance that the number will be below 75. Exactly what you need.
In this case, you only need the rand() function. Also note that, as @Marek suggested, a winning chance for an attacker could be well below 75%. (read Marek’s answer, which indicates a 57% chance of winning).
The problem arises when you need to model a more complex probability density function, for example:

In this case, you will need a more complex model, such as a Gaussian mixture .
dynamic
source share