0
$\begingroup$

I can't reproduce by hand Mathematica's PearsonChiSquareTest[dataset1,dataset2] on two datasets of discrete rand variables, with lengths N1 and N2, N1 much less than N2. (I just want to understand what it's doing).

I assume Mathematica determines B bins (using B=Ceiling[2*N1^0.4] - note the N1.), applies this to dataset2, and uses these to bin the datasets. The chisqr (as per NumC recipes and elsewhere) is not the sum over $i$ of:

($K*u(i)-v(i)/K)^2/(u(i)+v(i))$,

where $u$ and $v$ are the bin frequencies for the 2 datasets, and K=Sqrt[N2/N1]. Using this I get chisqr's scattered near, but below what M finds. Btw, bin delimiters are from Quantile[dataset2, Range[0.,1,1/B]].

Unfortunately, the HypothesisTestData property doesn't contain enough info to really see what's going on. Maybe Mathematica chooses bins differently? or uses a correction to the formula above?

Thanks for any insights.

Peter

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.