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

[Bug]: zipf_distribution support is incomplete (q < 1 is unsupported right now) #1818

Open
gajjanag opened this issue Jan 31, 2025 · 2 comments

Comments

@gajjanag
Copy link

Describe the issue

See comment at https://github.com/abseil/abseil-cpp/blob/master/absl/random/zipf_distribution.h#L38 regarding q > 1 precondition. We have use cases that require zipf q < 1.

This is mathematically well defined since the distribution is discrete over an alphabet [0, k]. q > 1 restriction only mathematically applies if one is sampling over the infinite range distribution [0, 1, ...].

Steps to reproduce the problem

N/A, code at HEAD (0f102ad)

What version of Abseil are you using?

0f102ad

What operating system and version are you using?

Linux

What compiler and version are you using?

N/A

What build system are you using?

N/A

Additional context

We require q < 1 for certain internal modeling at Meta.

@derekmauro
Copy link
Member

@laramiel

@gajjanag
Copy link
Author

gajjanag commented Feb 5, 2025

Implementation note: there is a rejection sampler available at https://github.com/rust-random/rand/blob/master/rand_distr/src/zipf.rs for reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants