9
votes

I'm trying to fit a von Mises distribution, from scipy (http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.vonmises.html)

So I tried

from scipy.stats import vonmises
kappa = 3
r = vonmises.rvs(kappa, size=1000)
plt.hist(r, normed=True,alpha=0.2)

It returns

enter image description here

However, when I fit the data on it

vonmises.fit(r)
# returns (1.2222011312461918, 0.024913780423670054, 2.4243546157480105e-30)

vonmises.fit(r, loc=0, scale=1)
# returns (1.549290021706847, 0.0013319431181202394, 7.1653626652619939e-29)

But none of the value returned is the parameter of Von Mises, kappa.

What is the returning value? Ifeel the second is loc, or mean value. But have no idea what the first returned value is.

And how should I fit a von mises distribution?

1
the returned values, in order, are kappa, loc, scale. - dbliss

1 Answers

12
votes

The returned values are kappa, loc and scale. Unfortunately, the von Mises pdf does not seem to yield itself to fitting. It does fit correctly if you fix the scale:

>>> vonmises.fit(r, fscale=1)
(2.994517240859579, -0.0080482378119089287, 1)