[SciPy-user] scipy.stats.lognorm.rvs signature

John Hunter jdh2358@gmail....
Mon Jun 16 14:32:03 CDT 2008


Is there a bug in the rvs method of scipy.stats.lognorm?

In [241]: scipy.__version__
Out[241]: '0.7.0.dev4388'

In [242]: dist = scipy.stats.lognorm()

In [243]: dist.rvs(10)
------------------------------------------------------------
Traceback (most recent call last):
  File "<ipython console>", line 1, in ?
  File "/home/titan/johnh/dev/lib/python2.4/site-packages/scipy/stats/distributions.py",
line 117, in rvs
    return self.dist.rvs(*self.args,**kwds)
  File "/home/titan/johnh/dev/lib/python2.4/site-packages/scipy/stats/distributions.py",
line 446, in rvs
    vals = reshape(self._rvs(*args),size)
TypeError: _rvs() takes exactly 2 arguments (1 given)



I was trying to plot empirical histograms against the pdf with the
following script when I bunped into this:

import matplotlib.pyplot as plt
import scipy.stats

for name in 'uniform', 'norm', 'expon', 'lognorm':
    print 'making', name
    dist = getattr(scipy.stats, name)()
    samples = dist.rvs(1000)
    fig = plt.figure()
    ax = fig.add_subplot(111)
    n, bins, patches = ax.hist(samples, 30, normed=True,
facecolor='blue', alpha=0.5)
    ax.set_title(name)
    ax.grid(True)
    binc = 0.5*(bins[1:]+bins[:-1])
    p = dist.pdf(binc)
    ax.plot(binc, p, lw=2, color='black')

plt.show()


More information about the SciPy-user mailing list