DIPlib Documentation - ©1995-2015 Quantitative Imaging Group, Delft University of Technology.

# BinaryRandomVariable

Binary random variable generator

## SYNOPSIS

`#include "dip_noise.h"`

dip_Error dip_BinaryRandomVariable ( random, input, p10, p01, output )

## FUNCTION

The binary random variable is generated by altering the input value, if the value of a generated random variable is higher than the `p10` probability, if `input` is `DIP_TRUE`, or higher than `p01` otherwise.

See `RandomVariable` for more information on the random number generator.

## ARGUMENTS

Data type | Name | Description
`dip_Random *` | `random` | Pointer to a random value structure
`dip_Boolean` | `input` | Input
`dip_float` | `p10` | Probability of a one to zero transition
`dip_float` | `p01` | Probability of a zero to one transition

## EXAMPLE

Get a binary random variable as follows:

       dip_Random random;
       dip_float p10, p01, value;

       p10 = 0.1;
       p01 = 0.2;
       DIPXJ( dip_RandomSeed( &random, 0 ));
       DIPXJ( dip_BinaryRandomVariable( &random, 1, p10, p01,  &value ));

## SEE ALSO

`RandomVariable`, `RandomSeed`, `RandomSeedVector`, `UniformRandomVariable`, `GaussianRandomVariable`, `PoissonRandomVariable`