On this page
numpy.random.geometric
- numpy.random.geometric(p, size=None)
- 
    Draw samples from the geometric distribution. Bernoulli trials are experiments with one of two outcomes: success or failure (an example of such an experiment is flipping a coin). The geometric distribution models the number of trials that must be run in order to achieve success. It is therefore supported on the positive integers, k = 1, 2, ....The probability mass function of the geometric distribution is where pis the probability of success of an individual trial.Note New code should use the geometricmethod of adefault_rng()instance instead; seerandom-quick-start.- Parameters
- 
      - pfloat or array_like of floats
- 
        The probability of success of an individual trial. 
- sizeint or tuple of ints, optional
- 
        Output shape. If the given shape is, e.g., (m, n, k), thenm * n * ksamples are drawn. If size isNone(default), a single value is returned ifpis a scalar. Otherwise,np.array(p).sizesamples are drawn.
 
- Returns
- 
      - outndarray or scalar
- 
        Drawn samples from the parameterized geometric distribution. 
 
 See also - Generator.geometric
- 
       which should be used for new code. 
 ExamplesDraw ten thousand values from the geometric distribution, with the probability of an individual success equal to 0.35: >>> z = np.random.geometric(p=0.35, size=10000)How many trials succeeded after a single run? >>> (z == 1).sum() / 10000. 0.34889999999999999 #random
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
 https://numpy.org/doc/1.19/reference/random/generated/numpy.random.geometric.html