When I use the code :
Random r = new Random();
r.nextBool();
It returns a 50% / 50% probability value (true / false).
How can I generate a true-false value with my own probability like (20% / 35% / 70% ...)?
Simpler example:
Random r = new Random();
bool result = r.nextDouble() <= 0.7;
Gives a chance of 70% to get True result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With