MATLAB - Maximum value for a periodic function (angles)

MATLAB stats textbooks have a section called “Installing a More Complex Distribution: A Mix of Two Normals” http://www.mathworks.com/help/stats/examples/fitting-custom-univariate-distributions.html

pdf_normmixture = @(x,p,mu1,mu2,sigma1,sigma2) ...
                     p*normpdf(x,mu1,sigma1) + (1-p)*normpdf(x,mu2,sigma2);
lb = [0 -Inf -Inf 0 0];
ub = [1 Inf Inf Inf Inf];
start = [pStart muStart sigmaStart sigmaStart];
paramEsts = mle(x, 'pdf',pdf_normmixture, 'start',start, 'lower',lb, 'upper',ub)

I would like to apply the same methodology to fit two or more normals to a one-dimensional set of values ​​that I have, but in the periodic domain . That is, angles that have values ​​from 0 ° to 360 °, connected together as a circular range. I'm not sure how to declare it so MATLAB understands this terminology.

Is it possible to change this implementation to add a round range?

Regards, Ignacio

+5
source share
1 answer

I use the von Mises distribution http://en.wikipedia.org/wiki/Von_Mises_distribution , which is considered to be a close approximation to the wrapped normal state (see the conditions in the sections in the section "circular statistics S. Rao Jammaladadak, A. Sen Gupta") Unfortunately, I do not have the Matlab test, but I think the code works. Thus, something similar can be done if the approximation is true:

The main function:

% you must specify theta vector column 0-2pi

n=size(theta,1);

mu=0;

k=1;

theParameters=[mu;k];
options = optimset('TolFun',0.01);
outputPar = fminsearch('ml',theParameters,options,n,theta);

ML function

function mLike=ml(theParameters,n,theta)

mu=theParameters(1,1);
k=theParameters(2,1);

theSum=0;
for i=1:n
   theSum=theSum+k*cos(theta(i,1)-mu);
end    
mLike=-n*log(2*pi*besselj(0,k)) + theSum;
mLike=-mLike;

I hope this helps! R also has a toolbar that does this assessment http://cran.r-project.org/web/packages/circular/circular.pdf .

k, , k = exp (kk) kk.

+1

All Articles