Popular Python recipes tagged "meta:requires=matplotlib.pylab"http://code.activestate.com/recipes/langs/python/tags/meta:requires=matplotlib.pylab/2005-05-13T15:58:00-07:00ActiveState Code RecipesMetropolis-Hastings Sampler (Python) 2005-05-13T15:58:00-07:00Flávio Codeço Coelhohttp://code.activestate.com/recipes/users/2434632/http://code.activestate.com/recipes/414200-metropolis-hastings-sampler/ <p style="color: grey"> Python recipe 414200 by <a href="/recipes/users/2434632/">Flávio Codeço Coelho</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). </p> <p>The Metropolis-Hastings Sampler is the most common Markov-Chain-Monte-Carlo (MCMC) algorithm used to sample from arbitrary probability density functions (PDF). Suppose you want to simulate samples from a random variable which can be described by an arbitrary PDF, i.e., any function which integrates to 1 over a given interval. This algorithm will do just that, as illustrated by the Plot done with Matplotlib. Notice how the samples follow the theoretical PDF.</p> Gibbs Sampler (Python) 2005-05-11T18:01:57-07:00Flávio Codeço Coelhohttp://code.activestate.com/recipes/users/2434632/http://code.activestate.com/recipes/413086-gibbs-sampler/ <p style="color: grey"> Python recipe 413086 by <a href="/recipes/users/2434632/">Flávio Codeço Coelho</a> . Revision 2. </p> <p>The gibbs sampler is an iterative conditional sampler from multidimensional probability density functions (PDFs). The resulting sample is plotted as a scatter plot with the Matplotlib module.</p>