randomFloat()
This function returns a random real-valued number.
Example
#include <Plaquette.h>
DigitalOut led(13);
void begin() {
}
void step() {
// 2% probability to toggle the LED
if (randomFloat() < 0.02)
led.toggle();
}
Reference
-
float pq::randomFloat()
Generates a uniform random number in the interval [0,1).
-
float pq::randomFloat(float max)
Generates a uniform random number in the interval [0,max).
-
float pq::randomFloat(float min, float max)
Generates a uniform random number in the interval [min,max) (b>a).