Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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[1]>0)&par[2]>0) return(-sum(dchisq(data,df=par[1],ncp=par[2],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
up vote 3 down vote accepted

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$.

share|improve this answer
Doh, so simple! This is great - I had already tried fitting chi-2 just by taking the mean but I was not sure it was theoretically correct (compared to maximum likelihood). – thrope Dec 14 '12 at 14:36
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.