# CDF of VOn Mises distribution

23 views (last 30 days)
Aep on 18 Aug 2021
Edited: David Goodmanson on 19 Aug 2021
Hello all,
How can I calculate cdf of Von Mises distribution with MATLAB?
Thanks
Aep on 18 Aug 2021
Thanks @KSSV. I had searched in the circular statistics toolbox, however it seems that it does not calculate the CDF of Von Mises distribution. The other code that you sent also, as far as I understood, generates random Von Mises distribution, but it does not calculate CDF.

David Goodmanson on 18 Aug 2021
Edited: David Goodmanson on 19 Aug 2021
HI Aep,
This is straight numerical integration and provides the cdf at 1e6 equally spaced points in theta, from -pi to pi.
kappa = 3;
mu = 1;
theta = linspace(-pi,pi,1e6);
f = exp(kappa*cos(theta-mu))/(2*pi*besseli(0,kappa));
c = cumtrapz(theta,f); % cdf
plot(theta,c)
c(end)-1 % check to see how close the last point of the cdf is to 1
ans = 2.0650e-14
% assume a set of angles theta1 with -pi <= theta1 <= pi;
theta1 = [.7 1.4 2.1];
c1 = interp1(theta,c,theta1,'spline')
c1 = 0.3148 0.7455 0.9578
For any reasonable kappa the last point of the cdf will be very close to 1, but the look of the plot depends on how far the maximum of f (at theta = mu) is from the starting point. Here the starting point is -pi, but it could be anywhere on the circle.
For an array of input angles of your choosing, interp1 provides the result.

Paul on 18 Aug 2021
This code seems to recreate one of the CDF plots on the linked wikipedia page. It doesn't run very fast.
syms x mu kappa x0 real
syms j integer
phi(x,mu,kappa) = 1/2/sym(pi)*(x + 2/besseli(0,kappa)*symsum(besseli(j,kappa)*sin(j*(x-mu))/j,j,1,inf));
F(x,mu,kappa,x0) = phi(x,mu,kappa) - phi(x0,mu,kappa);
cdf = F(-pi:.1:pi,0,1,-pi); % mu = 0, kappa = 1, support from -pi to pi
plot(-pi:.1:pi,double(cdf))
xlim([-pi pi]);
set(gca,'XTick',(-1:.5:1)*pi);
set(gca,'XMinorTick','on');
set(gca,'XMinorGrid','on');
grid

Jeff Miller on 19 Aug 2021
The Von Mises distribution is included in Cupid. You could use it like this to calculate CDF values:
>> location = 10;
>> concentration = 1.5;
>> vm = VonMises(location,concentration);
>> vm.CDF(11)
ans =
0.84863