I’m a researcher working on Bayesian computing and want to use Chapel for my next research project.

Are there any libraries (or code examples) on how to draw samples from a normal distribution (statistics) in Chapel?

Best regards

Nico

I’m a researcher working on Bayesian computing and want to use Chapel for my next research project.

Are there any libraries (or code examples) on how to draw samples from a normal distribution (statistics) in Chapel?

Best regards

Nico

Hi Nico —

I dragged my feet a little in answering this because I don't consider myself an expert on statistics in computing, so was hoping someone else would answer first. But I also don't want the weekend to pass without someone acknowledging your question (so hope that someone more knowledgeable than me might follow up).

As far as I know, the closest thing we have to this in the base Chapel installation is the `Random`

module which has some routines like `choice`

that *may* be useful for this context (?): PCGRandom — Chapel Documentation 1.24 But I also wouldn't be surprised if this wasn't what you need.

Checking our open issues, I'm also seeing some that look loosely related thematically:

- Sampling from a probability distribution · Issue #9806 · chapel-lang/chapel · GitHub
- Develop Probability distributions a' la R, SciPy, Spark, etc · Issue #6852 · chapel-lang/chapel · GitHub
- Chapel bindings for GSL - GNU's Probability and Statistics Library · Issue #12743 · chapel-lang/chapel · GitHub

The last one is particularly interesting, as it points to a community member (@npadmana) who had been incrementally adding support for calling GSL routines from Chapel over time.

I'll mention that if there's an existing C library that does what you want (and it's not already covered by Nikhil's GSL work), Chapel's interoperability features should let you make use of it fairly easily and we could provide help in terms of getting up and running with that (beyond what's in the documentation, e.g.: C Interoperability — Chapel Documentation 1.24).

I'll also mention that, in practice, a lot of times the way that Chapel libraries come about is that someone does a minimal wrapping of the C routines first, and then someone creates a "Chapeltastic" version that makes the interfaces cleaner / simpler / more like Chapel code and less like C. And then, if the capability would benefit from a native Chapel implementation (e.g., maybe it can be parallelized nicely?), we look into implementing the routines in Chapel directly.

Hope this is helpful,

-Brad