Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I used Mathematica's function PearsonChiSquareTest to test whether the data were drawn from a normal distribution.

As in the reference, I expected Mathematica to compare the result to a normal distribution, by running: PearsonChiSquareTest[data]. As I wanted to extract the test statistics from properties, I was "forced" to name the distribution I wanted to compare it to, namely the normal distribution: PearsonChiSquareTest[data, NormalDistribution[],"PValue"].
What is surprising is that the PValue for the first case is different from the second case where I use the Normal Distribution explicitly. Anyone knows what's the difference here?

data = RandomVariate[NormalDistribution[], 10^4];

PearsonChiSquareTest[data]

(*
==> 0.3248593157
*)

PearsonChiSquareTest[data, NormalDistribution[]]

(*
==> 0.4704917701
*)
share|improve this question

1 Answer 1

up vote 12 down vote accepted

According to the documentation you linked, difference is:

  • PearsonChiSquareTest[data, NormalDistribution[]] tests whether the data is distributed according to a normal distribution of mean 0 and standard deviation 1.
  • PearsonChiSquareTest[data] is actually more flexible, and checks whether your data is distributed according to any normal distribution.

The difference becomes flagrant with data from a different distribution:

data = RandomVariate[NormalDistribution[1, 0.1], 10^4];
PearsonChiSquareTest[data]
(* Out[33]= 0.419701 *)

PearsonChiSquareTest[data, NormalDistribution[]]
(* Out[34]= 2.712072730217051*10^-23123 *)

In short, the following two statements are equivalent:

PearsonChiSquareTest[data]
PearsonChiSquareTest[data, NormalDistribution[μ, Σ]]

where the second one uses symbolic parameters in the distribution. You can retrieve information about the test by doing:

PearsonChiSquareTest[data, NormalDistribution[μ, Σ], "HypothesisTestData"]

and exploring the different properties of this object. All properties can be listed by:

PearsonChiSquareTest[data, NormalDistribution[μ, Σ], "HypothesisTestData"]["Properties"]

and the fitted distribution is recovered with:

PearsonChiSquareTest[data, NormalDistribution[μ, Σ], "HypothesisTestData"]["FittedDistribution"]

Enjoy!

share|improve this answer
    
and: in the example given in the question, there is more evidence to reject the H0 "any normal dist" than H0 N(0,1)? this seems a little counter intuitive... –  PeriodicProgrammer Apr 15 '12 at 19:18
    
@PeriodicProgrammer I suppose that the test statistic includes the fact that by optimizing the fit parameters you are capitalizing on chance. So I guess p will be adjusted. BTW if you -re-run the example you can see the rank order of the p values may differ from run to run. –  Sjoerd C. de Vries Apr 15 '12 at 20:05
2  
@F'x Nice close reading of the docs. It is easy to interpret "tests whether data is normally distributed" as "tests whether data is distributed as N(0,1)". The docs could have been somewhat more explicit here. –  Sjoerd C. de Vries Apr 15 '12 at 20:09
    
thank you for your detailed and very helpful answer! I was unaware while conducting the tests, that while using NormDist[] it does directly use N(0,1), even though in retrospect it seems somehow logical :P. –  PeriodicProgrammer Apr 15 '12 at 20:12

Your Answer

 
discard

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.