Learning Degrees of Freedom/Shape Parameter for Student-t
-
Friday, March 02, 2012 3:50 PM
Hello,
In addition to the obvious mean and precision/variance parameters, is it possible to use Infer.net to learn the degrees of freedom or shape parameter for a student-t distribution from a provided data set? And if so, what is an appropriate prior distribution for the dof parameter?
Regards,
Philip
All Replies
-
Monday, March 05, 2012 4:09 PMOwner
(Apologies for the earlier spam reply now deleted)
We do have code in to learn shape of a gamma (which would give you dof), but it is not working correctly right now (it is still a work in progress). The best you can do is learn the rate of a gamma which relates to the variance of the student-t (considered as a Gaussian with uncertain precision). So in the code below, shape can only be a constant or observed, whereas rate can be a random variable.
double[] xdata = new double[] {1, 2, 3}; //var shape = Variable.GammaFromShapeAndRate(2, 2).Named("shape"); var shape = 1.0; var rate = Variable.GammaFromShapeAndRate(2, 2).Named("rate"); var tau = Variable.GammaFromShapeAndRate(shape, rate).Named("tau"); var mean = 1.0; var n = new Range(xdata.Length).Named("n"); var x = Variable.Array<double>(n).Named("x"); x[n] = Variable.GaussianFromMeanAndPrecision(mean, tau).ForEach(n); x.ObservedValue = xdata; var engine = new InferenceEngine(new VariationalMessagePassing()); Console.WriteLine("rate = {0}", engine.Infer(rate));John -
Thursday, May 31, 2012 7:54 PM
John--
Thanks for the clarification. The earlier response had indeed struck me as odd.
Regards,
Philip
-
Thursday, October 04, 2012 10:20 AMLearning the shape of a gamma is now supported in version 2.5. In the code posted by John Guiver, you can use the first (commented-out) definition of 'shape'.