[SciPy-User] How do I use vonmises.fit()?
josef.pktd@gmai...
josef.pktd@gmai...
Tue Mar 30 15:34:56 CDT 2010
On Tue, Mar 30, 2010 at 3:10 PM, David Ho <itsdho@ucla.edu> 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.
>>>> scipy.stats.distributions.vonmises.fit(vm_rvs)
> 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))
>>> plt.show()
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
distributions.
It might be possible to patch vonmises to work on the real line but I
never tried.
Josef
>
> --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~ =
(x-loc)/scale
If the standard distribution has mean or variance different from 0, 1
then the transformed distribution has mean and variance different from
loc, scale.
the stats method shows the implied variance scale:
>>> scipy.stats.vonmises.stats(1.2, loc=2.3, scale=2)
(array(2.2999999999999998), array(5.4900668161122423))
>>> scipy.stats.vonmises.stats(1.2, loc=0, scale=1)
(array(1.5832118030775403e-017), array(1.3725167040280606))
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
More information about the SciPy-User
mailing list