gonum / stat

Statistics package for Go [DEPRECATED]
195 stars 23 forks source link

Distribution Interface #28

Closed jonlawlor closed 7 years ago

jonlawlor commented 9 years ago

It seems like the dist package could use an interface that all distributions satisfy. Currently it only has ParameterMarshaler, but all of the distributions have:

CDF(x float64) float64
Entropy() float64
ExKurtosis() float64
LogProb(x float64) float64
LogSurvival(x float64) float64
Mean() float64
Median() float64
NumParameters() int
Prob(x float64) float64
Quantile(p float64) float64
Rand() float64
Skewness() float64
StdDev() float64
Survival(x float64) float64
Variance() float64

Although it seems like some of the other methods (such as Mode and Fit) would also be candidates for a Distribution interface. I'd like to start a discussion on what the dist package's goals are as well.

btracey commented 9 years ago

The signatures were designed with interfaces in mind, but I was leaning toward not having them until it was clear what methods should belong together. I would like a sampling package that has MCMC, Importance Sampling, Latin-Hypercube, etc. It's not clear how these should look because of the univariate/multivariate problem. Those aren't goals for the dist package specifically, but they bigger picture ideas.

jonlawlor commented 9 years ago

I guess E-M and bayesian estimation would also be applications. I'm going to flesh out some of the tests, and then I'll try to write up multivariate normal. From there I might take a stab at some sampling.

btracey commented 9 years ago

I've been playing with multivariate normal. Part of my motivation for the PRs on Symmetric and Triangular was to implement MVGauss. The covariance matrix should be symmetric. You need to compute the Cholesky decomposition to find probabilities, and Cholesky should return a triangular matrix.

In any event, it's still not clear to me if it should be in dist or in a different package mvdist. I'm leaning to one package right now, but I've felt strongly in the other direction in the past.

Here's what I have at the moment. There are lots of things wrong with it, but it's better than starting from scratch. http://play.golang.org/p/zjyKjDeR7H

btracey commented 7 years ago

After a lot more development, I think interfaces this big are not a good idea. Instead, we should focus on what the smaller interfaces needed for specific purposes.