mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Improve docstring for random.binomialvariate (gh-131164)
Add probability distribution to the docstring
This commit is contained in:
parent
776ec1e167
commit
25f24b01e3
1 changed files with 8 additions and 2 deletions
|
@ -792,12 +792,18 @@ class Random(_random.Random):
|
|||
|
||||
sum(random() < p for i in range(n))
|
||||
|
||||
Returns an integer in the range: 0 <= X <= n
|
||||
Returns an integer in the range:
|
||||
|
||||
0 <= X <= n
|
||||
|
||||
The integer is chosen with the probability:
|
||||
|
||||
P(X == k) = math.comb(n, k) * p ** k * (1 - p) ** (n - k)
|
||||
|
||||
The mean (expected value) and variance of the random variable are:
|
||||
|
||||
E[X] = n * p
|
||||
Var[x] = n * p * (1 - p)
|
||||
Var[X] = n * p * (1 - p)
|
||||
|
||||
"""
|
||||
# Error check inputs and handle edge cases
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue