I have a simple question about randomly generating numbers in Octave/Matlab.
How do I randomly generate a (one!) number (that is either 0 or 1)?
I could really use an example.
Thanx
Use rand, which generates a uniform pseudo-random number in the range 0..1, and then test this value against a suitable threshold, e.g. 0.5 for equal probability of 1 or 0:
r = rand > 0.5
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