Function PGARandomFlip

Function Documentation

int PGARandomFlip(PGAContext *ctx, double p)

Flip a biased coin and return true if the coin is a “winner”.

Example

To return PGA_TRUE approximately seventy percent of the time, use

PGAContext *ctx;
int bit;

...
bit = PGARandomFlip (ctx, 0.7)

Parameters
  • ctx – context variable

  • p – biased probability (.5 is a fair coin)

Returns

true if coin flip is a winner