# How to minimize Chi-Square using the CDF instead of the PDF?

Suppose one has data that is suspected to obey a normal distribution. One computes a histogram of the data, and performs Pearson's Chi-Squared Test. To perform this test, one must compare the observed counts from each bin in the histogram against the expected counts in the corresponding bins by the formula below:

To compute the expected counts, one integrates the probability density function of the normal distribution from the left bin-edge to the right bin-edge for all bins using fixed parameters mu and sigma. The smallest Chi-Squared statistic (assuming the associated pvalue is not too high or too low) should correspond to the fixed parameters that best fit the data.

(If anything is incorrect, please correct me).

I have read that a better optimization technique is to use the cdf instead of the pdf. If one still wanted to use the cdf (instead of the pdf) in conjunction with Pearson's Chi-Squared Test to optimize the distribution fit, how would one go about this?

My initial thought is that the histogram of observations should be converted into a cumulative histogram, such that the expected counts can be obtained from the integration of the cdf instead of the pdf. Is this wrong?

(I am asking because I have a lognormal dataset; the Chi-Square fit of looks great but the pvalue is small enough to be approximated as zero. Any advice or corrections regarding misunderstood information would be appreciated).

## 1 Answer

CDF is the integral of PDF from negative infinity. The CDF values don't tell you the expected counts in each bin because as mentioned, it starts the integration from negative infinity.

You will need to apply integration for each bin endpoint.

• The integration starts at negative infinity, but I think the CDF will be zero from -inf until the first bin. Are you saying that to apply this Chi-Squared Test with the CDF, I would integrate the first bin from -inf to the first right-side bin-edge, would integrate the second bin from -inf to the second right-side bin-edge, etc. ? – user146123 Oct 5 '18 at 5:44