Answered by:
retrieving draws from Gibbs sampling (Migrated from community.research.microsoft.com)

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
-
TimSal replied on 09-21-2010 10:22 AM
Great! Thanks for the quick reply!
- Marked as answer by Microsoft Research Friday, June 3, 2011 6:03 PM
Friday, June 3, 2011 6:03 PM -
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
- Edited by John GuiverMicrosoft employee, Owner Wednesday, January 4, 2012 4:45 PM
- Proposed as answer by FuriousEskimo Thursday, January 5, 2012 1:35 PM
- Marked as answer by John GuiverMicrosoft employee, Owner Thursday, January 5, 2012 1:40 PM
Wednesday, January 4, 2012 4:44 PMOwner
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!
- Marked as answer by Microsoft Research Friday, June 3, 2011 6:03 PM
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 307Wednesday, 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
- Edited by John GuiverMicrosoft employee, Owner Wednesday, January 4, 2012 4:45 PM
- Proposed as answer by FuriousEskimo Thursday, January 5, 2012 1:35 PM
- Marked as answer by John GuiverMicrosoft employee, Owner Thursday, January 5, 2012 1:40 PM
Wednesday, January 4, 2012 4:44 PMOwner -
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