Learning Degrees of Freedom/Shape Parameter for Student-t RRS feed

  • Question

  • 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?



    Friday, March 2, 2012 3:50 PM

All replies

  • (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));
    Monday, March 5, 2012 4:09 PM
  • John--

         Thanks for the clarification. The earlier response had indeed struck me as odd.



    Thursday, May 31, 2012 7:54 PM
  • Learning 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'.
    Thursday, October 4, 2012 10:20 AM