Cool. The training functions look good, but there's a problem with the pdf function. I'm surprised it compiles for you right now. We want pdf to take only two arguments: the distribution and a data point. It should be able to infer the values of mu, sigma2, and df from the values of the raw moments stored in Moments3. What I've done for other distributions is find the formulas for converting between raw moments and parameters through wikipedia and wolfram, and then it takes a little bit of reworking the equations to get them in a useful form. You can look at the implementation of Normal for an easy example.
Since there's three parameters, you will probably need to keep track of the third moment. This would mean implementing a Moments4 type that's just like Moments3 except keeps the third moment as well. Moments3 stops at the second, so maybe I should change its name.
Cool. The training functions look good, but there's a problem with the pdf function. I'm surprised it compiles for you right now. We want
pdf
to take only two arguments: the distribution and a data point. It should be able to infer the values ofmu
,sigma2
, anddf
from the values of the raw moments stored inMoments3
. What I've done for other distributions is find the formulas for converting between raw moments and parameters through wikipedia and wolfram, and then it takes a little bit of reworking the equations to get them in a useful form. You can look at the implementation ofNormal
for an easy example.Here's some links for getting these equations:
http://en.wikipedia.org/wiki/Student_t#Moments http://mathworld.wolfram.com/Studentst-Distribution.html
Since there's three parameters, you will probably need to keep track of the third moment. This would mean implementing a
Moments4
type that's just likeMoments3
except keeps the third moment as well.Moments3
stops at the second, so maybe I should change its name.I hope that makes sense :)