Search code examples
pythonmcmcpymc

Using pymc diagnostics and posterior summaries on samples not from pymc


I'd like to use the pymc diagnostic and summary functions on samples I have generated without using pymc. As one example, I'd like to use pymc's mc_error routine on my own set of samples.

Some of the pymc diagnostic functions can take an np.array of samples, but, if I understand correctly, others seem to require a trace object. How can I convert my own set of samples into a trace object that pymc can handle? I'd appreciate any pointers.

My samples are currently stored as a dictionary where each key is a name of a variable I am sampling and points to an np.array of samples.

Thanks!


Solution

  • Are you talking about the batchsd function? That is what is used to calculate the MC error in PyMC 2. Its located in the pymc.database.base module, and can be used on any array, really.

    The pymc.diagnostics module contains all the convergence diagnostics functions, and should work on numpy arrays.