# Loop and list all p-values (percentage and not histogram)

I have the following Mathematica code (see below). It currently provides a histogram as the solution. Instead of a histogram I want to count the number of times the p-value calculated surpasses a certain level so I can get a percentage of those times it would fail to reject or reject the hypothesis test at the $\alpha$ level set. So for each test, I should get a percentage below or equal to the p-value and a (1-percentage) above the p-value. Also, is there a way that if you have the histograms already that you can pull the actual values which Mathematica used to make the histogram?

DD[a_, b_, c_, μ_, ν_, σ_, τ_] =
MixtureDistribution[{a, b, c, a, b, c},
{NormalDistribution[-μ, τ],
NormalDistribution[-ν, σ],
NormalDistribution[-μ - ν, σ + τ],
NormalDistribution[μ, τ],
NormalDistribution[ν, σ],
NormalDistribution[μ + ν, σ + τ]}];

tests = {AndersonDarlingTest, CramerVonMisesTest,
KolmogorovSmirnovTest, KuiperTest, PearsonChiSquareTest,
WatsonUSquareTest};

n = 100;(* change to your larger number, i.e., 1000 *)

pValues =
Table[
data = RandomVariate[\[ScriptD] = JohnsonDistribution["SU", 0, 1, 0, 1], 1000];
(*Target Distributions here*)
data1 = RandomVariate[f = DD[0.46, 0.435, 0.105, 0, 0, 0.671, 1.7], 1000];
(*SIGMA goes here*)
#[data, f, SignificanceLevel -> 0.01] & /@ tests, {n}
] // Transpose;

Partition[
Histogram[#[[2]], PlotLabel -> #[[1]]] & /@
Transpose[{tests, pValues}],
2] // Grid


The counts:

Count[#, _?(# > 0.05 &)] & /@ pValues
(* {81, 98, 95, 87, 70, 91} *)


or as percentages:

100./n Count[#, _?(# > 0.05 &)] & /@ pValues
(* {81., 98., 95., 87., 70., 91.} *)


And if you have only the histograms left, you can extract the data as follows:

{45, 26, 13, 8, 3, 3, 2

Play with the indices to get the results for the various parts in the grid.

• How to you get the symbol after the a_]? It won't take colon and right arrow. – dsmalenb May 31 '15 at 23:56
• It's a colon and greater than symbol (RuleDelayed). – Sjoerd C. de Vries Jun 1 '15 at 5:49