Hypergeometric functions

Quick math-library design question: some of the math library hypergeometric functions (e.g.-F32) provide a result via a return value, some of them (grad_2F1) provide a result through an output argument passed as reference (T&), and some (grad_F32) provde the result through an output argument passed as pointer to array (grad_F32 writes to a six-value array).

I can standardize these. What’s the policy for scalar results? What about when there are multiple results?

I really don’t care, I just don’t want to have to dig through the rest of the math library and try to infer given that some of our code has been updated to current practices and some hasn’t.

The lack of uniformity is intentional.

If it’s a simple object, returning a value is fine and is almost always simpler.

If the object being constructed, passing an existing one in to be modified can sometimes make sense for efficiency (e.g., refilling in a vector in a loop rather than constructing a new one each loop or passing in our log density accumulator or passing in an output stream).

So you’ll have to use your judgement. By requiring arrays/containers as arguments, it forces their autodiff types to all be the same, so there are bigger consequences in terms of effiiciency and calling permutations.

Perfect, I won’t touch it.

Are there any plans to bring these Hypergeometric functions to Stan?

We usually do use cases first so… got a use case? Exposing something in Stan is easy once it’s in math. You can probably already use it with the right #include

No sure if that is a use case. I always do different perspectives of my models.
So, I try from time to time new distribution functions. And then compare them
with loo. I tried quite a lot of functions, bi-variate negative binomial, extreme value
Sichel, etc. I don’t publish the results, nor I wrote some “nice” scripts to
generate html. I’m not part of any university or similar. The most importance to
me is to improve my models.
Recently I came to some functions they require these functions. Unfortunately this paper is not free, but
popular.

Bacon with Your Eggs? Applications of a New Bivariate Beta-Binomial Distribution
American Statistician (2005)

  • Peter J Danaher, University of Melbourne

I understand. The problem for us is that without clear motivating examples, it’s hard for us to prioritize adding new features we don’t have immediate uses for. We have a lot on our to-do list.

I really wish statisticians wrote arXiv papers.

2 Likes

Hi - I came across this old discussion and thought I would add my use-case…

There is a type of time series model called a “Generalised ARMA” model. Originally explored by Shelton Peiris in 2003. For some work I was doing I wanted to calculate the theoretical autocorrelation function, as given in the paper below.

This requires hypergeometric functions.

Now I totally understand this is very much a 1-off and not exactly something that will help a lot of people, but thought I would add it in in case there are others with use-cases which might help.

paper: https://www.maths.usyd.edu.au/u/shelton/IMPRCOCHININV.doc

(*Theorems 3.1 & 3.2 are the culprits here).

btw for now I will settle with a numerical integration of the spectral density, which should give an approx ACF. So this is not urgent for me.

Many thanks!
Richard Hunt.