-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathcirc_vmpdf.m
46 lines (42 loc) · 1.22 KB
/
circ_vmpdf.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function [p, alpha] = circ_vmpdf(alpha, thetahat, kappa)
%
% [p alpha] = circ_vmpdf(alpha, thetahat, kappa)
% Computes the circular von Mises pdf with preferred direction thetahat
% and concentration kappa at each of the angles in alpha
%
% The vmpdf is given by f(phi) =
% (1/(2pi*I0(kappa))*exp(kappa*cos(phi-thetahat)
%
% Input:
% alpha angles to evaluate pdf at, if empty alphas are chosen to
% 100 uniformly spaced points around the circle
% [thetahat preferred direction, default is 0]
% [kappa concentration parameter, default is 1]
%
% Output:
% p von Mises pdf evaluated at alpha
% alpha angles at which pdf was evaluated
%
%
% References:
% Statistical analysis of circular data, Fisher
%
% Circular Statistics Toolbox for Matlab
% By Philipp Berens and Marc J. Velasco, 2009
% velasco@ccs.fau.edu
% if no angles are supplied, 100 evenly spaced points around the circle are
% chosen
if nargin < 1 || isempty(alpha)
alpha = linspace(0, 2*pi, 101)';
alpha = alpha(1:end-1);
end
if nargin < 3
kappa = 1;
end
if nargin < 2
thetahat = 0;
end
alpha = alpha(:);
% evaluate pdf
p = exp( kappa*(cos(alpha-thetahat)-1) ) / (2*pi*besseli(0,kappa,1));
end