[SciPy-User] How do I use vonmises.fit()?
Tue Mar 30 15:34:56 CDT 2010
On Tue, Mar 30, 2010 at 3:10 PM, David Ho <firstname.lastname@example.org> wrote:
> Hi all!
> I want to fit some data with a Von Mises distribution, and get the mean and
> "kappa" parameters for that distribution.
> I'm a little confused about scipy.stats.distributions.vonmises.fit().
> Just as a test, I tried this:
>>>> vm_rvs = scipy.stats.vonmises.rvs(1.2, 2.3, size=10000) # the first
>>>> argument appears to be "kappa", and the second argument is the mean.
> array([ 1.17643696e-01, 3.38956854e-03, 1.27331662e-27])
> I got an array of 3 values, none of which seem to be equal to the mean or
> kappa of the distribution.
> I looked around in some of the docstrings, but I couldn't find any clear
> documentation of what these values are supposed to correspond to.
> I would've expected vonmises.fit() to return something like:
> array([ 1.2, 2.3])
> What am I doing wrong?
> Thanks for your help,
When I did I check of the fit method for all distributions, then
vonmises most of the time didn't produce any useful results,
especially estimated scale of almost zero.
The problem is that vonmises doesn't have a well defined pdf on the real line
>>> import matplotlib.pyplot as plt
>>> plt.plot(scipy.stats.vonmises.pdf(np.linspace(-10,10),1.2, loc=2.3))
Since vonmises is intended for circular data, and I don't know much
about circular statistics (except for what Anne explained on the
mailing list), I never tried to get it to work like the other
It might be possible to patch vonmises to work on the real line but I
> --David Ho
> PS: I also don't fully understand the "scale" and "loc" parameters for all
> of the continuous random variables.
> Does "loc" always correspond to the mean, and "scale" always correspond to
> the square root of the variance, or something else?
loc=0, scale=1 is the standard distribution, the loc and scale
parameters transform the distribution of the transformation x~ =
If the standard distribution has mean or variance different from 0, 1
then the transformed distribution has mean and variance different from
the stats method shows the implied variance scale:
>>> scipy.stats.vonmises.stats(1.2, loc=2.3, scale=2)
>>> scipy.stats.vonmises.stats(1.2, loc=0, scale=1)
> SciPy-User mailing list
More information about the SciPy-User