Efficient fitting of noncentral chi-squared distribution to data?

I am looking for the most efficient way to fit a noncentral chi-squared distribution with fixed d.o.f. to a given data set. So the inputs are d.o.f. and the data and the output should be the noncentrality parameter that gives the best (maximum likelihood? or any other approach that would be more computationally efficient).

Since on Wikipedia the expression for the noncentral chi2 pdf is an infinite sum of chi2 I am at a bit of a loss as to where to start. Might it be possible to find an analytic MLE for the noncentrality in case of fixed dof? Or any other tricks or cancellations that might simplify the likelihood calculation in this special case.

• Thanks - I am using MATLAB and have implemented a similar approach using mle and ncx2pdf etc but it is extremely slow so I am looking to implement a more efficient approach myself. – thrope Dec 14 '12 at 14:35
• What is the sample size? In R, it takes less than $1$ second to botain the MLE using a sample size $n=1000$. Chek data = rchisq(1000,1,1); ll = function(par){ if(par>0)&par>0) return(-sum(dchisq(data,df=par,ncp=par,log=T))) else return(Inf) }; optim(c(1,1),ll). – user10525 Dec 14 '12 at 14:46
• OK maybe "extremely slow" was a bit strong. It takes me 0.5s for a sample size of 10000... but this is something I will need to perform many times so I really want it to be as fast as possible. – thrope Dec 14 '12 at 14:50

Just use the method of moments : the mean of a non central chi square $\chi^2(k,\lambda)$ is $k+\lambda$, ($k$ is the dof and $\lambda$ the ncp). So take $\lambda$ equal to the mean of the data minus $k$.
• If the underlying distribution of your data is really a $\chi^2(k,\lambda)$ this is enough. For theoretical considerations, read Wikipedia on the method of moments – Elvis Dec 14 '12 at 14:48