1 ## Copyright (C) 2009 Soren Hauberg <soren@hauberg.org>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} @var{theta} = vmpdf (@var{x}, @var{mu}, @var{k})
18 ## Evaluates the Von Mises probability density function.
20 ## The Von Mises distribution has probability density function
22 ## f (@var{x}) = exp (@var{k} * cos (@var{x} - @var{mu})) / @var{Z} ,
24 ## where @var{Z} is a normalisation constant. By default, @var{mu} is 0 and
29 function p = vmpdf (x, mu = 0, k = 1)
32 error ("vmpdf: first input must be real");
36 error ("vmpdf: second input must be a scalar");
39 if (!isreal (k) || k <= 0)
40 error ("vmpdf: third input must be a real positive scalar");
44 Z = 2 * pi * besseli (0, k);
45 p = exp (k * cos (x-mu)) / Z;