How does one get Sage to make random choices?
Like say in the middle of a code I compute a function value f(x) and I knwo that 0≤f(x)≤1. Now I want to write an if-then-else which will do one option with probability f(x) and the other otion with probability 1−f(x). How does one make Sage do this?
Can somoen kindly show a template example to simulate this?