title: MCMC Sampling a Maxwellian Curve Using Python's emcee
body: <p>I am trying to introduce myself to MCMC sampling with emcee. I want to simply take a sample from a Maxwell Boltzmann distribution using a set of example code on github, <a href="https://github.com/dfm/emcee/blob/master/examples/quickstart.py" rel="nofollow noreferrer">https://github.com/dfm/emcee/blob/master/examples/quickstart.py</a>. </p>
  
  <p>The example code is really excellent, but when I change the distribution from a Gaussian to a Maxwellian, I receive the error, <em>TypeError: lnprob() takes exactly 2 arguments (3 given)</em></p>
  
  <p>However it is not called anywhere where it is not given the appropriate parameters? In need of some guidance as to how to define a Maxwellian Curve and have it fit into this example code. </p>
  
  <p>Here is what I have; </p>
  
  <pre><code>    from __future__ import print_function
  import numpy as np
  import emcee
  
  try:
      xrange
  except NameError:
      xrange = range
  def lnprob(x, a, icov):
      pi = np.pi
      return np.sqrt(2/pi)*x**2*np.exp(-x**2/(2.*a**2))/a**3
  
  ndim = 2
  means = np.random.rand(ndim)
  
  cov  = 0.5-np.random.rand(ndim**2).reshape((ndim, ndim))
  cov  = np.triu(cov)
  cov += cov.T - np.diag(cov.diagonal())
  cov  = np.dot(cov,cov)
  
  
  icov = np.linalg.inv(cov)
  
  
  nwalkers = 50
  
  
  p0 = [np.random.rand(ndim) for i in xrange(nwalkers)]
  
  
  sampler = emcee.EnsembleSampler(nwalkers, ndim, lnprob, args=[means, icov])
  
  pos, prob, state = sampler.run_mcmc(p0, 5000)
  
  sampler.reset()
  
  sampler.run_mcmc(pos, 100000, rstate0=state)
  </code></pre>
  
  <p>Thanks</p>