Skip to content

Commit 69d1caa

Browse files
committed
Deploying to gh-pages from @ 1f9240b 🚀
1 parent 4e3775d commit 69d1caa

File tree

526 files changed

+715
-808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

526 files changed

+715
-808
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: ea1dff499fc8e995abc2adf43ef4b04f
3+
config: e598c293df90486acc6b4a8d8021316d
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_sources/library/random.rst.txt

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ instance of the :class:`random.Random` class. You can instantiate your own
3434
instances of :class:`Random` to get generators that don't share state.
3535

3636
Class :class:`Random` can also be subclassed if you want to use a different
37-
basic generator of your own devising: in that case, override the :meth:`~Random.random`,
38-
:meth:`~Random.seed`, :meth:`~Random.getstate`, and :meth:`~Random.setstate` methods.
39-
Optionally, a new generator can supply a :meth:`~Random.getrandbits` method --- this
40-
allows :meth:`randrange` to produce selections over an arbitrarily large range.
37+
basic generator of your own devising: see the documentation on that class for
38+
more details.
4139

4240
The :mod:`random` module also provides the :class:`SystemRandom` class which
4341
uses the system function :func:`os.urandom` to generate random numbers
@@ -88,7 +86,7 @@ Bookkeeping functions
8886

8987
.. versionchanged:: 3.11
9088
The *seed* must be one of the following types:
91-
*NoneType*, :class:`int`, :class:`float`, :class:`str`,
89+
``None``, :class:`int`, :class:`float`, :class:`str`,
9290
:class:`bytes`, or :class:`bytearray`.
9391

9492
.. function:: getstate()
@@ -412,6 +410,37 @@ Alternative Generator
412410
``None``, :class:`int`, :class:`float`, :class:`str`,
413411
:class:`bytes`, or :class:`bytearray`.
414412

413+
Subclasses of :class:`!Random` should override the following methods if they
414+
wish to make use of a different basic generator:
415+
416+
.. method:: Random.seed(a=None, version=2)
417+
418+
Override this method in subclasses to customise the :meth:`~random.seed`
419+
behaviour of :class:`!Random` instances.
420+
421+
.. method:: Random.getstate()
422+
423+
Override this method in subclasses to customise the :meth:`~random.getstate`
424+
behaviour of :class:`!Random` instances.
425+
426+
.. method:: Random.setstate(state)
427+
428+
Override this method in subclasses to customise the :meth:`~random.setstate`
429+
behaviour of :class:`!Random` instances.
430+
431+
.. method:: Random.random()
432+
433+
Override this method in subclasses to customise the :meth:`~random.random`
434+
behaviour of :class:`!Random` instances.
435+
436+
Optionally, a custom generator subclass can also supply the following method:
437+
438+
.. method:: Random.getrandbits(k)
439+
440+
Override this method in subclasses to customise the
441+
:meth:`~random.getrandbits` behaviour of :class:`!Random` instances.
442+
443+
415444
.. class:: SystemRandom([seed])
416445

417446
Class that uses the :func:`os.urandom` function for generating random numbers
@@ -445,30 +474,30 @@ Examples
445474

446475
Basic examples::
447476

448-
>>> random() # Random float: 0.0 <= x < 1.0
477+
>>> random() # Random float: 0.0 <= x < 1.0
449478
0.37444887175646646
450479

451-
>>> uniform(2.5, 10.0) # Random float: 2.5 <= x <= 10.0
480+
>>> uniform(2.5, 10.0) # Random float: 2.5 <= x <= 10.0
452481
3.1800146073117523
453482

454-
>>> expovariate(1 / 5) # Interval between arrivals averaging 5 seconds
483+
>>> expovariate(1 / 5) # Interval between arrivals averaging 5 seconds
455484
5.148957571865031
456485

457-
>>> randrange(10) # Integer from 0 to 9 inclusive
486+
>>> randrange(10) # Integer from 0 to 9 inclusive
458487
7
459488

460-
>>> randrange(0, 101, 2) # Even integer from 0 to 100 inclusive
489+
>>> randrange(0, 101, 2) # Even integer from 0 to 100 inclusive
461490
26
462491

463-
>>> choice(['win', 'lose', 'draw']) # Single random element from a sequence
492+
>>> choice(['win', 'lose', 'draw']) # Single random element from a sequence
464493
'draw'
465494

466495
>>> deck = 'ace two three four'.split()
467-
>>> shuffle(deck) # Shuffle a list
496+
>>> shuffle(deck) # Shuffle a list
468497
>>> deck
469498
['four', 'two', 'ace', 'three']
470499

471-
>>> sample([10, 20, 30, 40, 50], k=4) # Four samples without replacement
500+
>>> sample([10, 20, 30, 40, 50], k=4) # Four samples without replacement
472501
[40, 10, 50, 30]
473502

474503
Simulations::
@@ -572,14 +601,14 @@ Simulation of arrival times and service deliveries for a multiserver queue::
572601
including simulation, sampling, shuffling, and cross-validation.
573602

574603
`Economics Simulation
575-
<https://nbviewer.jupyter.org/url/norvig.com/ipython/Economics.ipynb>`_
604+
<https://nbviewer.org/url/norvig.com/ipython/Economics.ipynb>`_
576605
a simulation of a marketplace by
577606
`Peter Norvig <https://norvig.com/bio.html>`_ that shows effective
578607
use of many of the tools and distributions provided by this module
579608
(gauss, uniform, sample, betavariate, choice, triangular, and randrange).
580609

581610
`A Concrete Introduction to Probability (using Python)
582-
<https://nbviewer.jupyter.org/url/norvig.com/ipython/Probability.ipynb>`_
611+
<https://nbviewer.org/url/norvig.com/ipython/Probability.ipynb>`_
583612
a tutorial by `Peter Norvig <https://norvig.com/bio.html>`_ covering
584613
the basics of probability theory, how to write simulations, and
585614
how to perform data analysis using Python.

about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ <h3>瀏覽</h3>
308308
<br />
309309
<br />
310310

311-
最後更新於 Dec 28, 2023 (15:24 UTC)。
311+
最後更新於 Dec 29, 2023 (05:53 UTC)。
312312
<a href="/bugs.html">Found a bug</a>?
313313
<br />
314314

bugs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ <h3>瀏覽</h3>
344344
<br />
345345
<br />
346346

347-
最後更新於 Dec 28, 2023 (15:24 UTC)。
347+
最後更新於 Dec 29, 2023 (05:53 UTC)。
348348
<a href="/bugs.html">Found a bug</a>?
349349
<br />
350350

c-api/abstract.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ <h3>瀏覽</h3>
318318
<br />
319319
<br />
320320

321-
最後更新於 Dec 28, 2023 (15:24 UTC)。
321+
最後更新於 Dec 29, 2023 (05:53 UTC)。
322322
<a href="/bugs.html">Found a bug</a>?
323323
<br />
324324

c-api/allocation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ <h3>瀏覽</h3>
332332
<br />
333333
<br />
334334

335-
最後更新於 Dec 28, 2023 (15:24 UTC)。
335+
最後更新於 Dec 29, 2023 (05:53 UTC)。
336336
<a href="/bugs.html">Found a bug</a>?
337337
<br />
338338

c-api/apiabiversion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ <h3>瀏覽</h3>
364364
<br />
365365
<br />
366366

367-
最後更新於 Dec 28, 2023 (15:24 UTC)。
367+
最後更新於 Dec 29, 2023 (05:53 UTC)。
368368
<a href="/bugs.html">Found a bug</a>?
369369
<br />
370370

c-api/arg.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ <h3>瀏覽</h3>
875875
<br />
876876
<br />
877877

878-
最後更新於 Dec 28, 2023 (15:24 UTC)。
878+
最後更新於 Dec 29, 2023 (05:53 UTC)。
879879
<a href="/bugs.html">Found a bug</a>?
880880
<br />
881881

c-api/bool.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ <h3>瀏覽</h3>
329329
<br />
330330
<br />
331331

332-
最後更新於 Dec 28, 2023 (15:24 UTC)。
332+
最後更新於 Dec 29, 2023 (05:53 UTC)。
333333
<a href="/bugs.html">Found a bug</a>?
334334
<br />
335335

c-api/buffer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ <h3>瀏覽</h3>
10021002
<br />
10031003
<br />
10041004

1005-
最後更新於 Dec 28, 2023 (15:24 UTC)。
1005+
最後更新於 Dec 29, 2023 (05:53 UTC)。
10061006
<a href="/bugs.html">Found a bug</a>?
10071007
<br />
10081008

0 commit comments

Comments
 (0)