在pymc中采样时绘制迹线

时间:2014-12-11 14:31:22

标签: python pymc

有没有办法自动绘制一条跟踪迭代次数?我正在使用一个相对昂贵的模型,不时检查链条的状态会很好。

1 个答案:

答案 0 :(得分:0)

在PyMC 2.3中,您可以在控制台会话中使用isample(在IPython笔记本中不起作用)。这允许您暂停或将作业发送到后台。它看起来像这样:

In [7]: M.isample(20000)
==============
 PyMC console
==============

        PyMC is now sampling. Use the following commands to query or pause the sampler.


        Commands:
          i -- index: print current iteration index
          p -- pause: interrupt sampling and return to the main console.
                      Sampling can be resumed later with icontinue().
          h -- halt:  stop sampling and truncate trace. Sampling cannot be
                      resumed for this chain.
          b -- bg:    return to the main console. The sampling will still
                      run in a background thread. There is a possibility of
                      malfunction if you interfere with the Sampler's
                      state or the database during sampling. Use this at your
                      own risk.

pymc > p

这可以是一种长期检查的便捷方式。