Bernoulli-distributed Random Generator
Ir para navegação
Ir para pesquisar
This is a discrete probability distribution that can be thought of as a model for the set of possible outcomes of any single experiment that asks a yes-no question (or true-false). The single parameter is denoted p (probability of success).
Sample Python Code
def pseudo_bernoulli(p=0.5, size=1):
"""
Bernoulli generator from uniform generator
"""
# Sets seed based on the decimal portion of the current system clock
t = time.perf_counter()
seed = int(10**9*float(str(t-int(t))[0:]))
U = pseudo_uniform(seed=seed, size=size)
B = (U <= p).astype(int)
return B