rand_distr: Add Zipf distribution#1136
Conversation
|
cc @kaimast |
|
I did not compare to the reference implementation in numpy yet. |
dhardy
left a comment
There was a problem hiding this comment.
May be worth comparing this? https://jasoncrease.medium.com/rejection-sampling-the-zipf-distribution-6b359792cffa
On a first look, I'm not sure this method is different, but I would have to do the math to be sure. |
|
@dhardy The parametrization of the Zipf distribution you linked is different:
Which paramtrization should I implement? |
|
Sorry, I don't feel qualified to answer that. |
|
I also found an R library using the The Wikipedia calls |
This follows the naming convention on Wikipedia.
It seems like this is not true [1], at least not with the same exponent. [1] https://en.wikipedia.org/wiki/Zeta_distribution
Also inline the distribution methods.
This should improve performance slightly.
|
@dhardy I chose to implement both distributions. |
Arguably, the Zipf distribution is related to the Pareto distribution [1]. [1] https://en.wikipedia.org/wiki/Zipf's_law#Related_laws
|
Hi @vks! Looking at the previous comments you had quite a journey with names (and yeah, it is not very clear). But you got it right! I have looked only at the implementation of Naming I had a look at some references and leave a summary here. Maybe this is useful for the documentation, but I will leave it to you.
References |
There was some discussion in #987 and #1093, which resulted in some documentation in the Rand book. |
saona-raimundo
left a comment
There was a problem hiding this comment.
These are the comments about Zipf.
I have some disagreements with some of the computations, I tried to explain the reasoning in each case. Feel free to ask for more clarification.
Notably, I also propose to introduce one more error variant NTooBig.
|
Another case we might want to consider: For large |
|
Because this PR is already quite large, I would like to leave the extended distribution tests for a follow-up PR. |
saona-raimundo
left a comment
There was a problem hiding this comment.
@dhardy we are finished with the review and agree on adding distributional tests in a subsequent PR.
dhardy
left a comment
There was a problem hiding this comment.
Great. On that basis I approve merging. And thanks for stepping in to review.
|
@saona-raimundo Thanks for the extensive review! @dhardy Should I squash before merging? |
|
@vks can't say I care too much whether or not it gets squashed. The reason I didn't merge myself is because I wasn't quite sure whether you were ready to. |
rand_distr: Add Zipf distribution
Fixes #1069.