Skip to content
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

DOC: Fix typo in np.random.default_rng().logistic() #25355

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

linus-md
Copy link
Contributor

@linus-md linus-md commented Dec 9, 2023

This fixes a typo and uses the correct convention of: rng = np.random.default_rng(); rng.beta(...).

@linus-md linus-md changed the title DOC: Add example for np.random.default_rng().logistic() DOC: Add example for np.random.default_rng().logistic() Dec 9, 2023
@linus-md linus-md changed the title DOC: Add example for np.random.default_rng().logistic() DOC: Fix typo in np.random.default_rng().logistic() Dec 9, 2023
@eendebakpt
Copy link
Contributor

The changes in this PR look good. When reviewing I noticed that the scaling in the plotting (with count.max()) is not entirely correct. I would suggest the following:

loc, scale = 10, 1
rng = np.random.default_rng()
s = rng.logistic(loc, scale, 10000)
import matplotlib.pyplot as plt
count, bins, _ = plt.hist(s, bins=50)

#   plot against distribution
def logist(x, loc, scale):
     return np.exp((loc-x)/scale)/(scale*(1+np.exp((loc-x)/scale))**2)
logistic_values = logist(bins, loc, scale)
bin_spacing = np.mean(np.diff(bins))
plt.plot(bins, logistic_values * bin_spacing * s.size)
plt.show()

(not sure this should be part of this PR, I will leave that decision to the numpy devs)

@mattip
Copy link
Member

mattip commented Dec 14, 2023

here is the rendered page. I think we should just put this in for now as a bug fix (typo), and leave rescaling for a possible future PR.

@mattip mattip merged commit 2d72bc9 into numpy:main Dec 14, 2023
62 checks passed
@mattip
Copy link
Member

mattip commented Dec 14, 2023

Thanks @linus-md

@linus-md linus-md deleted the log-docs branch December 14, 2023 13:35
@eendebakpt
Copy link
Contributor

here is the rendered page. I think we should just put this in for now as a bug fix (typo), and leave rescaling for a possible future PR.

I created #25398 to address the scaling

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.

None yet

3 participants