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

Log Riemann Zeta plus Zipf distribution #28

syclik opened this Issue Jul 6, 2015 · 3 comments


None yet
4 participants
Copy link

syclik commented Jul 6, 2015

From @bob-carpenter on February 12, 2014 18:9

It'd be nice to have the Zipf distribution in Stan:


The pmf is involves the Riemann zeta function, which is available from Boost:

so we could add it directly with auto-diff. But auto-diffing these numerical
approximations to functions isn't ideal.

Plus, we really need log_zeta for Stan, and then we'd want a direct scheme
for evaluating both



  d/ds log(zeta(s)) = 1/zeta(s) d/ds zeta(s).

See also, this paper by Choudhury (1995), which is what the Mathworld page cites:

Copied from original issue: stan-dev/stan#551


This comment has been minimized.

Copy link

qdread commented Feb 20, 2018

I would also appreciate being able to evaluate the zeta function in Stan because I am trying to fit a piecewise distribution and it is needed to ensure smoothness at the breakpoint. Is there any way I can do this?


This comment has been minimized.

Copy link

bgoodri commented Feb 20, 2018


This comment has been minimized.

Copy link

bob-carpenter commented Feb 20, 2018

Looks like someone conveniently worked out the form of the derivative:

If you try to just use the templated form from Boost, it'll autodiff their iterative definition of zeta rather than implementing the approximate autodiff. The latter's usually more stable, though we've gotten many workable results from the former.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.