EASEA defined functions

De
Aller à la navigation Aller à la recherche

Random Number Generators

tossCoin

Description

Simulates a (possibly biased) toss of a coin.

EASEA syntax

bool tossCoin()   // returns true with probability .5
bool tossCoin(fBias)  // returns true with probability fBias, with fBias in [0,1]

tossCoin Example

if(tossCoin(.1)){ // 10% chance to execute this code
    ...
}

Random

Description

Generates a random number. There are several definitions to the random function:

  1. Random function with Min Max Boundary
  2. Random function with Max Boundary only

In the case of a Max boundary only, the Min boundary will be 0.

EASEA syntax

int random( int Min, int Max)
int random( int Max)
float random( float Min, float Max)
double random( double Min, double Max)