Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Draw more attention to which functions in random are convenience wrappers #13035

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

Merged
merged 2 commits into from
Feb 28, 2019

Conversation

eric-wieser
Copy link
Member

I've seen people complain in the past that randn(M, N) is inconsistent with zeros((M, N)). They're right, but they're missing the point that randn exists to be consistent with Matlab, not to be self-consistent with numpy.

Let's point those users more obviously to the function they're looking for.

This gives an error at least as far back as 1.12.x
@eric-wieser eric-wieser force-pushed the random-matlab-aliases branch 2 times, most recently from d40cb74 to 277e7c4 Compare February 25, 2019 05:10
tuple as the first argument, use `numpy.random.standard_normal` instead.
If positive int_like arguments are provided, `randn` generates an array
of shape ``(d0, d1, ..., dn)``, filled
with random floats sampled from a univariate "normal" (Gaussian)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need quotes around "normal".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherited from the old docstring

This is a convenience function. If you want an interface that takes a
tuple as the first argument, use `numpy.random.standard_normal` instead.
If positive int_like arguments are provided, `randn` generates an array
of shape ``(d0, d1, ..., dn)``, filled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well justify the text a bit more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes the diff noisier and the two commits harder to separate, would prefer not to


Notes
-----
For random samples from :math:`N(\\mu, \\sigma^2)`, use either of::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"one of::"?

@eric-wieser eric-wieser force-pushed the random-matlab-aliases branch from 277e7c4 to 1e96346 Compare February 26, 2019 07:37
@eric-wieser
Copy link
Member Author

Good suggestions, clearly I'm out of practice at writing docs.

@mattip
Copy link
Member

mattip commented Feb 26, 2019

Changes can be viewed at matlab for numpy, rand, randn

They seem to render nicely.

@eric-wieser
Copy link
Member Author

I was hoping that zeros and ones would be links, not italic.

@mattip
Copy link
Member

mattip commented Feb 26, 2019

Try to add numpy.?

`numpy.ones`

@mattip
Copy link
Member

mattip commented Feb 26, 2019

Once PRs #13002, #13033 and issue #13013 go in, the next step is to turn on warnings for all the bad references

@mattip
Copy link
Member

mattip commented Feb 27, 2019

@charris any more comments? The new material can be viewed at matlab for numpy, rand, randn, LGTM.

@eric-wieser
Copy link
Member Author

@mattip: I'd like to fix those references, but haven't had a chance. Feel free to take over to do it, else I'll try in 10 hours or so.

In response to twitter conversations that complain that `randn` is inconsistent with `zeros`, to which the answer is "that's because randn is a wrapper to make things look like matlab".
@eric-wieser
Copy link
Member Author

References updated

@eric-wieser eric-wieser force-pushed the random-matlab-aliases branch from 1e96346 to dac6fdc Compare February 28, 2019 05:12
@mattip
Copy link
Member

mattip commented Feb 28, 2019

The numpy.ones and numpy.zeros links in the note on the `randn' page now work. In it goes. Thanks Erirc

@mattip mattip merged commit b9ab1a5 into numpy:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants