CDF of VOn Mises distribution
45 views (last 30 days)
Show older comments
Hello all,
How can I calculate cdf of Von Mises distribution with MATLAB?
Thanks
4 Comments
Answers (3)
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.
0 Comments
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
0 Comments
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
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!