Ich berechne die Parameter einer Von Mises Verteilung von Hand und wollte mit der Scipy Von Mises Fitfunktion vergleichen.Schätzparameter von Von Mises Verteilung Scipy - Inkonsistente Antworten
Ich bekomme inkonsistente Ergebnisse von der Fit-Funktion.
My zwei Datensätze sind d1 = [0.8pi, 0.9pi] und d2 = [0.2pi, 0.1pi]
My Python Funktion unten ist:
def calc(data):
'''Takes a 1-D dataset and uses the scipy von mises to learn parameters and also calculates them by hand
using the regular M.L estimation for mean and the bannerjee et al (2005) approximation for concentraion factor
params: 1-D dataset in radians
'''
res = vonmises.fit(data, fscale=1)
mu = np.arctan(sum(np.sin(data))/sum(np.cos(data)))
A = sum(np.cos(data))*(1/len(data))*np.cos(mu)+sum(np.sin(data))*np.sin(mu)*(1/len(data))
k = A*(2-A**2)/(1-A**2)
print('mu and k by hand: ', mu, k)
print('mu and k from fit function', res[1],res[0])
Meine Ergebnisse sind wie folgt:
Ausgang:
>d1:
mu and k by hand: 0.471238898038 41.3480495503
mu and k from fit function 0.471238858132 40.8666881759
>d2:
mu and k by hand: -0.471238898038 -41.3480495503
mu and k from fit function 2.67035368203 40.8666556123
Wie Sie sehen können, th e mu für d2 ist anders. Das k hat ein anderes Vorzeichen. d1 ist jedoch sehr ähnlich.
Ich bin nicht sicher, warum diese Diskrepanz auftritt. Ich frage mich, ob es ein Problem mit meiner Schätzung von Hand gibt. Ich verwende die M.L.E-Schätzung aus Bishop's Pattern-Erkennungs-Lehrbuch S. 109. Jede Einsicht wird geschätzt.