# Noncentral Chi-square Distribution

While the chi-square distribution characterizes how the chi-square test statistic is distributed when the null hypothesis is assumed to be true, the noncentral chi-square distribution instead shows how the chi-square test statistic is distributed when the alternative hypothesis is assumed to be true (i.e. when the null hypothesis is assumed to be false). As such it is useful in calculating the power of the usual chi-square tests.

Definition 1: The noncentral chi-square distribution, abbreviated as χ2(k,λ), has the cumulative distribution function F(x), written as Fk,λ(x) when necessary, where k = the degree of freedom and non-negative λ = the noncentrality parameter.

where Gr(x) is the cumulative distribution function for the central chi-square distribution χ2(r).

Similarly the probability density function (pdf) is given by the formula

where gr(x) is the pdf for the central chi-square distribution χ2(r).

Observation: The mean of the noncentral chi-square distribution is k + λ. The variance is 2(k+2λ).

Observation: When λ = 0 the noncentral chi-square distribution is equal to the central chi-square distribution, i.e. χ2(k,0) = χ2(k).

Observation: The following chart shows the graphs of the noncentral chi-square distribution with 5 degrees of freedom for δ = 0, 2, 4, 6.

Figure 1 – Noncentral chi-square distribution

Real Statistics Function: The following function is provided in the Real Statistics Pack:

NCHISQ_DIST(x, df, λ, cum, iter, prec). If cum = TRUE then the value of the noncentral chi-square distribution χ2(df,λ) at x is returned, while if cum = FALSE then the value of the  pdf at x is returned.

NCHISQ_INV (p, df, λ, iter, iter0, prec) = the inverse of the cdf of the noncentral chi-square distribution χ2(df,λ) at p, i.e. the value of x such that NCHISQ(x, df, λ, TRUE, iter, prec) = p.

NCHISQ_NCP (p, df, x, iter, iter0, prec) = the value of the noncentrality parameter λ such the cdf of the noncentral distribution χ2(df,λ) at x is p, i.e. NCHISQ(x, df, λ, TRUE, iter, prec) = p.

Here iter = the maximum number of terms in the infinite sum that will be calculated (default 1000), prec = desired level of accuracy of the power calculation (default 0.000000001) and iter0 = the number of iterations used in calculating NCHISQ_INV and NCHISQ_NCP. Note that df can take any positive value and does not have to be an integer.

Note that NCHISQ_DIST(6,5,4,FALSE) = .087883 and NCHISQ_DIST(6,5,4,TRUE) = .317396, which is consistent with the values shown in the green curve of Figure 1.

### 23 Responses to Noncentral Chi-square Distribution

1. Xiaotong says:

Dear Mr./Ms.

I’m using the non-central chi square distribution function from real-statistics package. However, when the df is less then 1, it doesn’t work anymore. How can I deal with the situation with df less then 1?

Thank you so much

Xiaotong

• Charles says:

Xiaotong,
The reason that it doesn’t work is that Excel’s CHIDIST and CHISQ.DIST functions don’t work for df < 1 and the Real Statistics non-central chi-square function calls these Excel functions. I will make a change in the next release of the Real Statistics software to calculate the non-central chi-square distribution is a slightly different way so that values of df < 1 will be supported. Charles

• Xiaotong says:

Charles,
Thank you very much for your timely reply.
So when will you post the next release of the Real Statistics? Can’t wait to use it 🙂

Thank you a gain for this wonderful package.

Xiaotong

• Charles says:

Probably late next week, depending on how the testing goes.
Charles

• Xiaotong says:

Hi Charles,
Can you tell me once you post the latest version?
Thank you
Best
Xiaotong

• Charles says:

Hi Xiaotong,
You can get this information by following the Real Statistics website on Twitter by using @Real1Statistics. You can do this by clicking on the Follow @Real1Statistics icon.
Charles

2. Anthony Grieb says:

Figure 1 shows df=5 but the preceding reference says “10 degrees of freedom” is this a mistake?

• Charles says:

Anthony,
Yes, you are correct. Thank you very much for finding this error. I have now corrected the referenced webpage. I really appreciate your help in making the website better and more accurate.
Charles

3. The noncentral chi-square function is not available in my version of Excel 2016. How do I enable it?

• Charles says:

Seth,
Are you using the Real Statistics addin?
Are you using a Mac?
Charles

4. Evita says:

Hi Charles,
I am on a Mac using Excel 2011. I have tried several times to use the Add-In and have failed.

The first error message I get is “Can’t find project or library”. When I click Ok, it asks me for a Real-Stat password.

I have followed the instructions and don’t know what I am doing wrong. Do you have any ideas?

Thank!

• Charles says:

Evita,
You should never need to provide a password. Make sure that you downloaded the version of Real Statistics for the Mac Excel 2011.
See the following webpage. Instead of pressing Alt-TI, use the AddIns choice from the Tools menu.
Charles

• Evita Vulgaris says:

Charles,
I am still having the same problem. I removed the previous add-in and carefully repeated the download and installation steps again and I get the same error messages. The Solver add-in is already installed in my Excel and so all I should have to do when I go to the Add-Ins menu should be just click the box. I have Excel 2011 on a Mac and that is the version I have been selecting.

Do you have any idea what can be wrong?

Thanks.

• Charles says:

Evita,
Here are some possible reasons, although it looks like you have ruled out #2.
1. Try using one of the Real Statistics functions. In particular, enter the formula =VER() and see whether you get an error, in which case, the software has not been installed correctly
2. Solver has not been installed. When you choose the Add-Ins option from the Tools menu, do you see RealStats and Solver in the list of addins with a check mark next to them?
3. See Hint 2 at http://www.real-statistics.com/appendix/faqs/disappearing-addin
4. The problem might be with the Trust Center settings. Click on Options from the File ribbon and then choose the Trust Center option on the left side. Next click on Trust Center Settings …. Next click on the Macro Settings option on the left side and make sure that it is Disable all Macros with Notification. Also click on the Trusted Locations option on the left side and click on the Add New Location… button to add the folder that contains RealStats-2007 folder as a trusted location.
Charles

• Evita Vulgaris says:

Charles,
Unfortunately, I still cannot get it to worked.
1) Solver is installed
2) I tried =VER() and it returns “5.0 Excel Mac” so something installed but not completely or correctly.
3) I am using Excel 2011 on a Mac and Trust Center settings does not exist.
4) I do see “Real Statistics” in the bar at the top. However, I tried calling a couple of the functions that that I saw in these help pages and I either get an error or the wrong answer. Specifically:
a)”=NCHISQ_DIST(6,5,4,FALSE)” generates a pop-up with the message “Compile error in hidden module: NonCentral” as opposed to 0.087883
b) “=NT_DIST(6,5,4,TRUE)” gives 0.7870196 and not 0.317396 as shown in one of the help pages.

Does this help at all to identify the problem?

Thank you for all your help

• Charles says:

Evita,
I don’t see where the problem is. I am on vacation this weekend and don’t have my Mac with me. When I return on Tuesday, I will try to figure out what is happening. One further question: are you using an English-language version of Excel or some other language?
Charles

• Charles says:

Evita,
I found that when I used Real Statistics on my Mac I also got an error message when I tried to use the Descriptive Statistics data analysis tool. This worked fine the last time I tried it a few weeks ago.
In any case, the following approach resolved the problem for me. I suggest that you try it.
1. I opened a new Excel workbook and selected Add-Ins from the Tools menu and unchecked RealStats
2. Next I closed Excel and then reopened Excel
3. I selected Add-Ins from the Tools menu and then checked RealStats.
When I tried to use the Descriptive Statistics data analysis tool, it worked fine.
Charles

• Evita Vulgaris says:

I did not see a “Reply” link under your list response so I am responding here. I am using the English (default) language. If you want me to try anything else, please let me know.

Thanks again.

• Charles says:

Evita,
Thanks for your response. I will look into this problem when I return home on Tuesday.
Charles

• Evita Vulgaris says:

Charles,
I am sorry but I just saw your response – for some reason the posts are not listed in chronological order.

I tried what you suggested but unfortunately, to no avail. Specifically, in a new workbook, I unselected Real-Stats and then closed the workbook. When I reopened, I selected it again and got the usual error message : “Can’t find project or library” followed by being prompted for a password again. I selected OK and Cancel, respectively.

Also, inside the spreadsheet, I try to get values for some of the functions:
1) NCHISQ_DIST(6,5,4,FALSE) gives the error “Compile error in hidden module: NonCentral”
2) NT_DIST(6,5,4,TRUE) gives 0.7870196 which is incorrect (the correct value is 0.317396)

I don’t know if this information helps at all but I don’t what else to do.

Thanks.

• Charles says:

Evita,
1. Are you using Excel 2016 for the Mac. If so, try using the Real Statistics version for Excel 2016 (Mac).
If using Excel 2011, did you try using the Rel 3.5.3 version of the software?
2. The value for NT_DIST(6,5,4,TRUE) is correct (see http://keisan.casio.com/exec/system/1180573219). The value of =NCHISQ_DIST(6,5,4,TRUE) is .317396
Charles

• Evita Vulgaris says:

Thank you, Charles.

I am on Excel 2011 for the Mac. I uninstalled the version that I had downloaded previously and tried your suggesting – i.e., using Version 3.53. Everything works fine now.

I also checked the output given by NT_DIST(6,5,4,TRUE) against the other website and it agrees. As a note, you may want to update the last sentence under Figure 1 where it gives a value of 0.317396 for this as opposed to the correct value of 0.7879186.

I appreciate all your help. It is really nice to have a package like this!!

• Charles says:

Evita,
Glad to see that everything is working now.
Thanks also for catching the error on the webpage. I have now corrected the formula. I appreciate your help in improving the accuracy of the website.
Charles