On this page
random.binomialvariate
Prev: random.betavariate | Up: random | Next: random.choice
Rel: random.betavariate, random.choice, random.choices, random.expovariate
Ref: docs.python.org — random.binomialvariate
Tags: #public #python3 #stdlib #random
Import
import random
from random import binomialvariate
Signature & Overview
random.binomialvariate(n=1, p=0.5)
Binomial random variable.
Usage
import random
rng = random.Random(1)
hits = rng.binomialvariate(n=10, p=0.5)
assert 0 <= hits <= 10
Gotchas
- Requires Python 3.12+: Models the number of successes in
nindependent Bernoulli trials with probabilitypin[0.0, 1.0].
REPL Inspect
from random import binomialvariate
help(binomialvariate)
Linked from
- tuts/python3/stdlib_module/random
- tuts/python3/stdlib_module/random/betavariate
- tuts/python3/stdlib_module/random/choice
- tuts/python3/stdlib_module/random/choices
- tuts/python3/stdlib_module/random/expovariate
- tuts/python3/stdlib_module/random/gammavariate
- tuts/python3/stdlib_module/random/gauss
- tuts/python3/stdlib_module/random/getrandbits
- tuts/python3/stdlib_module/random/getstate
- tuts/python3/stdlib_module/random/lognormvariate
- tuts/python3/stdlib_module/random/normalvariate
- tuts/python3/stdlib_module/random/paretovariate
- tuts/python3/stdlib_module/random/randbytes
- tuts/python3/stdlib_module/random/randint
- tuts/python3/stdlib_module/random/random
- tuts/python3/stdlib_module/random/Random_class
- tuts/python3/stdlib_module/random/randrange
- tuts/python3/stdlib_module/random/sample
- tuts/python3/stdlib_module/random/seed
- tuts/python3/stdlib_module/random/setstate
- tuts/python3/stdlib_module/random/shuffle
- tuts/python3/stdlib_module/random/SystemRandom
- tuts/python3/stdlib_module/random/triangular
- tuts/python3/stdlib_module/random/uniform
- tuts/python3/stdlib_module/random/vonmisesvariate
- tuts/python3/stdlib_module/random/weibullvariate
Related notes
- tuts/python3/stdlib_module/random/betavariate Linked here; links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/choice Linked here; links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/choices Linked here; links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/expovariate Linked here; links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/random Linked here; links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/gammavariate links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/gauss links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/getrandbits links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/getstate links to this page; shared tags: #random, #stdlib
- tuts/python3/stdlib_module/random/lognormvariate links to this page; shared tags: #random, #stdlib