math icon indicating copy to clipboard operation
math copied to clipboard

Log Riemann Zeta plus Zipf distribution

Open syclik opened this issue 10 years ago • 3 comments

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

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

See: http://mathworld.wolfram.com/ZipfDistribution.html

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

http://www.boost.org/doc/libs/1_55_0/libs/math/doc/html/math_toolkit/zetas/zeta.html

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

log(zeta(s)

and

  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: https://www.jstor.org/stable/52768?seq=1#page_scan_tab_contents

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

syclik avatar Jul 06 '15 21:07 syclik

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?

qdread avatar Feb 20 '18 16:02 qdread

Stan needs to wrap it from Boost http://www.boost.org/doc/libs/1_66_0/libs/math/doc/html/math_toolkit/zetas/zeta.html

On Tue, Feb 20, 2018 at 11:25 AM, Quentin Read [email protected] wrote:

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?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/math/issues/28#issuecomment-367033301, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqtgi7MHBu-NVtO78-gDTn2M4RkzSks5tWvIVgaJpZM4FTDfv .

bgoodri avatar Feb 20 '18 17:02 bgoodri

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

https://proofwiki.org/wiki/Derivative_of_Riemann_Zeta_Function

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.

bob-carpenter avatar Feb 20 '18 17:02 bob-carpenter