# Generation of Binary number from some distribution function

In mathematica, RandomInteger[] generates binary numbers (0 or 1) with equal probablity (uniform distribution).

If I wish to generate the binary numbers with unequal probability or from some probability distribution, let's say Binomial distribution, then how to generate them?

For example, for 10 binomial numbers of length 5, you could use either BinomialDistribution (as shown by @Kuba in the comments) or RandomChoice

p = 1/10;

SeedRandom[0]

RandomVariate[BinomialDistribution[1, p], {10, 5}]

(* {{0, 0, 0, 0, 1}, {1, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, {0, 1, 0,
0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {1, 0, 0, 1, 0}, {1, 0, 0, 0,
0}, {0, 0, 0, 0, 0}} *)

SeedRandom[0]

RandomChoice[{1 - p, p} -> {0, 1}, {10, 5}]

(* {{0, 0, 0, 0, 1}, {1, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0}, {0, 1, 0,
0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {1, 0, 0, 1, 0}, {1, 0, 0, 0,
0}, {0, 0, 0, 0, 0}} *)


The approaches are equivalent

% == %%%

(* True *)