@@ -140,8 +140,8 @@ cdef bint _check_bit_generator(object bitgen):
140140
141141
142142cdef class Generator :
143- """
144- Generator(bit_generator)
143+ # the first line is used to populate `__text_signature__`
144+ """ Generator(bit_generator)\n --
145145
146146 Container for the BitGenerators.
147147
@@ -396,20 +396,20 @@ cdef class Generator:
396396 Drawn samples from the parameterized beta distribution.
397397
398398 Examples
399- --------
400- The beta distribution has mean a/(a+b). If ``a == b`` and both
399+ --------
400+ The beta distribution has mean a/(a+b). If ``a == b`` and both
401401 are > 1, the distribution is symmetric with mean 0.5.
402402
403403 >>> rng = np.random.default_rng()
404404 >>> a, b, size = 2.0, 2.0, 10000
405405 >>> sample = rng.beta(a=a, b=b, size=size)
406406 >>> np.mean(sample)
407407 0.5047328775385895 # may vary
408-
408+
409409 Otherwise the distribution is skewed left or right according to
410410 whether ``a`` or ``b`` is greater. The distribution is mirror
411411 symmetric. See for example:
412-
412+
413413 >>> a, b, size = 2, 7, 10000
414414 >>> sample_left = rng.beta(a=a, b=b, size=size)
415415 >>> sample_right = rng.beta(a=b, b=a, size=size)
@@ -422,12 +422,12 @@ cdef class Generator:
422422 -0.0003163943736596009 # may vary
423423
424424 Display the histogram of the two samples:
425-
425+
426426 >>> import matplotlib.pyplot as plt
427- >>> plt.hist([sample_left, sample_right],
427+ >>> plt.hist([sample_left, sample_right],
428428 ... 50, density=True, histtype='bar')
429429 >>> plt.show()
430-
430+
431431 References
432432 ----------
433433 .. [1] Wikipedia, "Beta distribution",
@@ -477,17 +477,17 @@ cdef class Generator:
477477
478478 Examples
479479 --------
480- Assume a company has 10000 customer support agents and the time
481- between customer calls is exponentially distributed and that the
480+ Assume a company has 10000 customer support agents and the time
481+ between customer calls is exponentially distributed and that the
482482 average time between customer calls is 4 minutes.
483483
484484 >>> scale, size = 4, 10000
485485 >>> rng = np.random.default_rng()
486486 >>> time_between_calls = rng.exponential(scale=scale, size=size)
487487
488- What is the probability that a customer will call in the next
489- 4 to 5 minutes?
490-
488+ What is the probability that a customer will call in the next
489+ 4 to 5 minutes?
490+
491491 >>> x = ((time_between_calls < 5).sum())/size
492492 >>> y = ((time_between_calls < 4).sum())/size
493493 >>> x - y
@@ -718,10 +718,10 @@ cdef class Generator:
718718
719719 Notes
720720 -----
721- This function generates random bytes from a discrete uniform
722- distribution. The generated bytes are independent from the CPU's
721+ This function generates random bytes from a discrete uniform
722+ distribution. The generated bytes are independent from the CPU's
723723 native endianness.
724-
724+
725725 Examples
726726 --------
727727 >>> rng = np.random.default_rng()
@@ -1024,9 +1024,9 @@ cdef class Generator:
10241024 greater than or equal to low. The default value is 0.
10251025 high : float or array_like of floats
10261026 Upper boundary of the output interval. All values generated will be
1027- less than high. The high limit may be included in the returned array of
1028- floats due to floating-point rounding in the equation
1029- ``low + (high-low) * random_sample()``. high - low must be
1027+ less than high. The high limit may be included in the returned array of
1028+ floats due to floating-point rounding in the equation
1029+ ``low + (high-low) * random_sample()``. high - low must be
10301030 non-negative. The default value is 1.0.
10311031 size : int or tuple of ints, optional
10321032 Output shape. If the given shape is, e.g., ``(m, n, k)``, then
@@ -1541,10 +1541,10 @@ cdef class Generator:
15411541 So there is about a 1% chance that the F statistic will exceed 7.62,
15421542 the measured value is 36, so the null hypothesis is rejected at the 1%
15431543 level.
1544-
1545- The corresponding probability density function for ``n = 20``
1544+
1545+ The corresponding probability density function for ``n = 20``
15461546 and ``m = 20`` is:
1547-
1547+
15481548 >>> import matplotlib.pyplot as plt
15491549 >>> from scipy import stats
15501550 >>> dfnum, dfden, size = 20, 20, 10000
@@ -1554,7 +1554,7 @@ cdef class Generator:
15541554 >>> plt.plot(x, stats.f.pdf(x, dfnum, dfden))
15551555 >>> plt.xlim([0, 5])
15561556 >>> plt.show()
1557-
1557+
15581558 """
15591559return cont (& random_f ,& self ._bitgen ,size ,self .lock ,2 ,
15601560dfnum ,'dfnum' ,CONS_POSITIVE ,
@@ -1701,7 +1701,7 @@ cdef class Generator:
17011701
17021702 The distribution of a chi-square random variable
17031703 with 20 degrees of freedom looks as follows:
1704-
1704+
17051705 >>> import matplotlib.pyplot as plt
17061706 >>> import scipy.stats as stats
17071707 >>> s = rng.chisquare(20, 10000)
@@ -1921,14 +1921,14 @@ cdef class Generator:
19211921 Does their energy intake deviate systematically from the recommended
19221922 value of 7725 kJ? Our null hypothesis will be the absence of deviation,
19231923 and the alternate hypothesis will be the presence of an effect that could be
1924- either positive or negative, hence making our test 2-tailed.
1924+ either positive or negative, hence making our test 2-tailed.
19251925
19261926 Because we are estimating the mean and we have N=11 values in our sample,
1927- we have N-1=10 degrees of freedom. We set our significance level to 95% and
1928- compute the t statistic using the empirical mean and empirical standard
1929- deviation of our intake. We use a ddof of 1 to base the computation of our
1927+ we have N-1=10 degrees of freedom. We set our significance level to 95% and
1928+ compute the t statistic using the empirical mean and empirical standard
1929+ deviation of our intake. We use a ddof of 1 to base the computation of our
19301930 empirical standard deviation on an unbiased estimate of the variance (note:
1931- the final estimate is not unbiased due to the concave nature of the square
1931+ the final estimate is not unbiased due to the concave nature of the square
19321932 root).
19331933
19341934 >>> np.mean(intake)
@@ -1947,18 +1947,18 @@ cdef class Generator:
19471947 >>> s = rng.standard_t(10, size=1000000)
19481948 >>> h = plt.hist(s, bins=100, density=True)
19491949
1950- Does our t statistic land in one of the two critical regions found at
1950+ Does our t statistic land in one of the two critical regions found at
19511951 both tails of the distribution?
19521952
19531953 >>> np.sum(np.abs(t) < np.abs(s)) / float(len(s))
19541954 0.018318 #random < 0.05, statistic is in critical region
19551955
1956- The probability value for this 2-tailed test is about 1.83%, which is
1957- lower than the 5% pre-determined significance threshold.
1956+ The probability value for this 2-tailed test is about 1.83%, which is
1957+ lower than the 5% pre-determined significance threshold.
19581958
19591959 Therefore, the probability of observing values as extreme as our intake
1960- conditionally on the null hypothesis being true is too low, and we reject
1961- the null hypothesis of no deviation.
1960+ conditionally on the null hypothesis being true is too low, and we reject
1961+ the null hypothesis of no deviation.
19621962
19631963 """
19641964return cont (& random_standard_t ,& self ._bitgen ,size ,self .lock ,1 ,
@@ -3034,21 +3034,21 @@ cdef class Generator:
30343034 Draw samples from the distribution:
30353035
30363036 >>> rng = np.random.default_rng()
3037- >>> n, p, size = 10, .5, 10000
3037+ >>> n, p, size = 10, .5, 10000
30383038 >>> s = rng.binomial(n, p, 10000)
30393039
30403040 Assume a company drills 9 wild-cat oil exploration wells, each with
3041- an estimated probability of success of ``p=0.1``. All nine wells fail.
3041+ an estimated probability of success of ``p=0.1``. All nine wells fail.
30423042 What is the probability of that happening?
30433043
3044- Over ``size = 20,000`` trials the probability of this happening
3044+ Over ``size = 20,000`` trials the probability of this happening
30453045 is on average:
30463046
30473047 >>> n, p, size = 9, 0.1, 20000
30483048 >>> np.sum(rng.binomial(n=n, p=p, size=size) == 0)/size
30493049 0.39015 # may vary
30503050
3051- The following can be used to visualize a sample with ``n=100``,
3051+ The following can be used to visualize a sample with ``n=100``,
30523052 ``p=0.4`` and the corresponding probability density function:
30533053
30543054 >>> import matplotlib.pyplot as plt
@@ -3167,10 +3167,10 @@ cdef class Generator:
31673167 appear before the third "1" is a negative binomial distribution.
31683168
31693169 Because this method internally calls ``Generator.poisson`` with an
3170- intermediate random value, a ValueError is raised when the choice of
3170+ intermediate random value, a ValueError is raised when the choice of
31713171 :math:`n` and :math:`p` would result in the mean + 10 sigma of the sampled
3172- intermediate distribution exceeding the max acceptable value of the
3173- ``Generator.poisson`` method. This happens when :math:`p` is too low
3172+ intermediate distribution exceeding the max acceptable value of the
3173+ ``Generator.poisson`` method. This happens when :math:`p` is too low
31743174 (a lot of failures happen for every success) and :math:`n` is too big (
31753175 a lot of successes are allowed).
31763176 Therefore, the :math:`n` and :math:`p` values must satisfy the constraint:
@@ -3302,7 +3302,7 @@ cdef class Generator:
33023302 >>> s = rng.poisson(lam=lam, size=size)
33033303
33043304 Verify the mean and variance, which should be approximately ``lam``:
3305-
3305+
33063306 >>> s.mean(), s.var()
33073307 (4.9917 5.1088311) # may vary
33083308
@@ -3456,7 +3456,7 @@ cdef class Generator:
34563456
34573457 Examples
34583458 --------
3459- Draw 10,000 values from the geometric distribution, with the
3459+ Draw 10,000 values from the geometric distribution, with the
34603460 probability of an individual success equal to ``p = 0.35``:
34613461
34623462 >>> p, size = 0.35, 10000
@@ -3475,7 +3475,7 @@ cdef class Generator:
34753475 >>> plt.plot(bins, (1-p)**(bins-1)*p)
34763476 >>> plt.xlim([0, 25])
34773477 >>> plt.show()
3478-
3478+
34793479 """
34803480return disc (& random_geometric ,& self ._bitgen ,size ,self .lock ,1 ,0 ,
34813481p ,'p' ,CONS_BOUNDED_GT_0_1 ,
@@ -4646,11 +4646,11 @@ cdef class Generator:
46464646 --------
46474647 shuffle
46484648 permutation
4649-
4649+
46504650 Notes
46514651 -----
4652- An important distinction between methods ``shuffle`` and ``permuted`` is
4653- how they both treat the ``axis`` parameter which can be found at
4652+ An important distinction between methods ``shuffle`` and ``permuted`` is
4653+ how they both treat the ``axis`` parameter which can be found at
46544654 :ref:`generator-handling-axis-parameter`.
46554655
46564656 Examples
@@ -4722,7 +4722,7 @@ cdef class Generator:
47224722if axis is None :
47234723if x .ndim > 1 :
47244724if not (np .PyArray_FLAGS (out )& (np .NPY_ARRAY_C_CONTIGUOUS |
4725- np .NPY_ARRAY_F_CONTIGUOUS )):
4725+ np .NPY_ARRAY_F_CONTIGUOUS )):
47264726flags = (np .NPY_ARRAY_C_CONTIGUOUS |
47274727NPY_ARRAY_WRITEBACKIFCOPY )
47284728to_shuffle = PyArray_FromArray (< np .PyArrayObject * > out ,
@@ -4802,8 +4802,8 @@ cdef class Generator:
48024802
48034803 Notes
48044804 -----
4805- An important distinction between methods ``shuffle`` and ``permuted`` is
4806- how they both treat the ``axis`` parameter which can be found at
4805+ An important distinction between methods ``shuffle`` and ``permuted`` is
4806+ how they both treat the ``axis`` parameter which can be found at
48074807 :ref:`generator-handling-axis-parameter`.
48084808
48094809 Examples
@@ -5011,11 +5011,11 @@ def default_rng(seed=None):
50115011 Examples
50125012 --------
50135013 `default_rng` is the recommended constructor for the random number class
5014- `Generator`. Here are several ways we can construct a random
5015- number generator using `default_rng` and the `Generator` class.
5014+ `Generator`. Here are several ways we can construct a random
5015+ number generator using `default_rng` and the `Generator` class.
50165016
50175017 Here we use `default_rng` to generate a random float:
5018-
5018+
50195019 >>> import numpy as np
50205020 >>> rng = np.random.default_rng(12345)
50215021 >>> print(rng)
@@ -5025,20 +5025,20 @@ def default_rng(seed=None):
50255025 0.22733602246716966
50265026 >>> type(rfloat)
50275027 <class 'float'>
5028-
5029- Here we use `default_rng` to generate 3 random integers between 0
5028+
5029+ Here we use `default_rng` to generate 3 random integers between 0
50305030 (inclusive) and 10 (exclusive):
5031-
5031+
50325032 >>> import numpy as np
50335033 >>> rng = np.random.default_rng(12345)
50345034 >>> rints = rng.integers(low=0, high=10, size=3)
50355035 >>> rints
50365036 array([6, 2, 7])
50375037 >>> type(rints[0])
50385038 <class 'numpy.int64'>
5039-
5039+
50405040 Here we specify a seed so that we have reproducible results:
5041-
5041+
50425042 >>> import numpy as np
50435043 >>> rng = np.random.default_rng(seed=42)
50445044 >>> print(rng)