Binomial-distributed Random Generator
Ir para navegação
Ir para pesquisar
It is the discrete probability distribution of a specific number of successes in a sequence of n independent experiments, each asking a yes-no question, and each with its own boolean-valued outcome: success with probability p or failure with probability
.Sample Python Code
def pseudo_binomial(n=100, p=0.5, size=1):
"""
Binomial generator from uniform generator
"""
binom = []
for _ in range(size):
# 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=n)
Y = (U <= p).astype(int)
binom.append(np.sum(Y))
return binom