locked
retrieving draws from Gibbs sampling (Migrated from community.research.microsoft.com) RRS feed

  • Question

  • TimSal posted on 09-21-2010 10:09 AM

    Quick question: I have just run a Gibbs sampling procedure and I would like to retrieve the generated draws for display/printing to file. How do I do this? Thanks in advance.

    Friday, June 3, 2011 6:03 PM

Answers

All replies

  • John Guiver replied on 09-21-2010 10:21 AM

    In the BugsRats tutorial example (for example), you can get the samples as follows:

    var betaCSamps = ie.Infer<SampleList<double>>(betaC, QueryTypes.Samples);

    John 

    Friday, June 3, 2011 6:03 PM
  • TimSal replied on 09-21-2010 10:22 AM

    Great! Thanks for the quick reply!

    Friday, June 3, 2011 6:03 PM
  • Hi.

    I love Infer.Net. It's a great package. I'm trying to get it up and running and replicating some of the features that I can access in OpenBugs currently.

    The above code doesn't seem to be working for me though.

    I added it after line 51 in the BugsRats.cs file (so my code looks like the below)

                    Gaussian betaCMarg = ie.Infer<Gaussian>(betaC);
                    var betaCSamps = ie.Infer<SampleList<double>>(betaC, QueryTypes.Samples);
                    Gaussian alpha0Marg = ie.Infer<Gaussian>(alpha0);
                    Gamma tauCMarg = ie.Infer<Gamma>(tauC);

    but I get the error below.

    Any ideas? Thanks in advance for the help!

    Wednesday, January 4, 2012 9:33 AM
  • Apologies. I forgot the error message. Thanks

    Example failed with exception: System.ArgumentException: Cannot convert distribution type ReadOnlyCollection<double> to type SampleList<double>
       at MicrosoftResearch.Infer.Distributions.Distribution.ChangeType[TReturn](Object distribution) in C:\infernetBuilds\12-10-2011_14-16\Runtime\Distributions\Distribution.cs:line 457
       at MicrosoftResearch.Infer.Models.User.Model_Gibbs.Marginal[T](String variableName, String query)
       at MicrosoftResearch.Infer.InferenceEngine.Infer[TReturn](IVariable var, QueryType queryType) in C:\infernetBuilds\12-10-2011_14-16\Compiler\Infer\InferenceEngine.cs:line 307

    Wednesday, January 4, 2012 10:47 AM
  • SampleList is no longer supported as a return type from Infer. Instead, do the following:

    var betaCSamps = ie.Infer<IList<double>>(betaC, QueryTypes.Samples);

    John 


    Wednesday, January 4, 2012 4:44 PM
    Owner
  • Hi John

    That works perfectly.

    Many thanks for the quick help!

    • Proposed as answer by FuriousEskimo Thursday, January 5, 2012 1:35 PM
    • Unproposed as answer by FuriousEskimo Thursday, January 5, 2012 1:35 PM
    Thursday, January 5, 2012 1:35 PM