Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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 \leq f(x) \leq 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?