bernoulli

Function bernoulli 

Source
pub fn bernoulli(n: usize, p: f64, seed: u64) -> Vec<u8> 
Expand description

Generate a Bernoulli bit sequence with probability p of each bit being 1.

Theoretical entropy: H(p) = -p*log2(p) - (1-p)*log2(1-p) bits/symbol.

Returns bytes where each byte is a sample (0 or 1).

§Arguments

  • n - Number of samples to generate
  • p - Probability of 1 (must be in [0, 1])
  • seed - Random seed for reproducibility

§Returns

Vector of n bytes, each being 0 or 1.