8000 Typo in python random.random documentation · Issue #101097 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Typo in python random.random documentation #101097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sherpaurgen opened this issue Jan 17, 2023 · 4 comments · Fixed by #101119
Closed

Typo in python random.random documentation #101097

sherpaurgen opened this issue Jan 17, 2023 · 4 comments · Fixed by #101119
Assignees
Labels
docs Documentation in the Doc dir

Comments

@sherpaurgen
Copy link
sherpaurgen commented Jan 17, 2023

There is a typo in documentation here regarding random.random()
the next random floating point number in the range [0.0, 1.0).

It can be corrected by replacing ")" with "]"

Linked PRs

@sherpaurgen sherpaurgen added the docs Documentation in the Doc dir label Jan 17, 2023
@hugovk
Copy link
Member
hugovk commented Jan 17, 2023

This isn't a typo, the opening square bracket [ means 0.0 is included.

And the closing round bracket ) means that 1.0 is excluded.

So the random number is >= 0.0 but < 1.0.

https://stackoverflow.com/a/4396303/724176

@kumaraditya303
Copy link
Contributor

It is using standard interval notation.

@kumaraditya303 kumaraditya303 added the pending The issue will be closed if no feedback is provided label Jan 17, 2023
@stevendaprano stevendaprano closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2023
@rhettinger
Copy link
Contributor

This has come up before. Apparently, the interval notation is not universally known and recognized. I will switch the 0.0 <= X < 1.0 which communicates the same information but without the notation that is cryptic to at least some readers.

@hugovk
Copy link
M 8000 ember
hugovk commented Jan 18, 2023

There's a few more we could change, at least those in docs:

$ git grep "\[[0-9.]*, [0-9.]*)"
Doc/faq/library.rst:This returns a random floating point number in the range [0, 1).
Doc/howto/functional.rst:    >>> # Generate 8 random numbers between [0, 10000)
Doc/library/random.rst:generates a random float uniformly in the semi-open range [0.0, 1.0).  Python
Doc/library/random.rst:   Return the next random floating point number in the range [0.0, 1.0).
Include/bytearrayobject.h: * the bytes are mapped to ints in [0, 256).
Lib/random.py:        # When x and y are two variables from [0, 1), uniformly
Lib/random.py:        """Get the next random number in the range [0.0, 1.0)."""
Lib/test/sortperf.py:    """Return a list of n random floats in [0, 1)."""
Modules/_randommodule.c:random() -> x in the interval [0, 1).
Modules/clinic/_randommodule.c.h:"random() -> x in the interval [0, 1).");
Objects/floatobject.c:        /* Normalize f to be in the range [1.0, 2.0) */
Objects/floatobject.c:        /* Normalize f to be in the range [1.0, 2.0) */
Objects/floatobject.c:        /* Normalize f to be in the range [1.0, 2.0) */
Python/dtoa.c:     * a number in the range [0.1, 1). */

rhettinger pushed a commit that referenced this issue Jan 22, 2023
…than signs for random.random()'s documentation (#101119)
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 22, 2023
… less than signs for random.random()'s documentation (pythonGH-101119)

(cherry picked from commit 8bcd4a6)

Co-authored-by: Andrew Hong <andrewhong@myyahoo.com>
miss-islington added a commit that referenced this issue Jan 22, 2023
…r less than signs for random.random()'s documentation (GH-101119) (GH-101246)

(cherry picked from commit 8bcd4a6)

Co-authored-by: Andrew Hong <andrewhong@myyahoo.com>

Automerge-Triggered-By: GH:rhettinger
Sign up for free to join this conversation on GitHub. Alrea 5422 dy have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
6 participants
0