Uniform $p$-values in $\chi^2$ fit? I seem to have gotten myself confused about uniform $p$-values assuming the null hypothesis. This is related to how we interpret the results. 
Say I have a  $\chi^2$-distribution which I got from fitting a series of tracks. By tracks I mean from particles passing through a pixel detector. Since we add a series of Gaussian distributions normalised by the estimated error together for each pixel sensor. We should expect a  $\chi^2$-distribution. If I sample from the  $\chi^2$-distribution then calculate the $p$-values, 
1)Should I expect the $p$-values to be uniform?
Since we sample the  $\chi^2$-distribution which is non uniform.
2 )If it is not uniform why?
 A: The $p$-value statistic is used frequently in physics, most notably in the search for the Higgs boson at the LHC.
The $p$-value (which I denote with $\lambda$) is the probability of obtaining such a large $\chi^2$ statistic by chance if the null hypothesis is true,
$$
\lambda = p(\chi^2 \ge \chi^2\text{ observed} | H_0)
$$
i.e. the area in the right-hand tail of the $\chi^2$-distribution,
$$
\lambda = \int_{\chi^2}^\infty p(\chi^{2 \prime}) . d\chi^{2 \prime}
$$
Consider the distribution of the $p$-value. Remembering that
$$
p(\lambda) d\lambda = p(\chi^2) d\chi^2,
$$
we quickly find
$$
p(\lambda) = p(\chi^2) \times \left|\frac{d \chi^2}{d\lambda}\right| = p(\chi^2) / p(\chi^2) = 1,
$$
where the differentiation follows from the definition of $\lambda$ above.We have shown that the $p$-value is uniformly distributed, as expected.
We calculate the derivative as follows:
$$
\frac{d \chi^2}{d\lambda} = \left(\frac{d \lambda}{d\chi^2}\right)^{-1} 
= \left(\frac{d\int_{\chi^2}^\infty p(\chi^{2 \prime}) . d\chi^{2 \prime}}{d\chi^2}\right)^{-1} 
= \left(\frac{d}{d\chi^2}(F(\infty) - F(\chi^2))\right)^{-1} = \frac{-1}{p(\chi^2)}
$$
where $F(\chi^2) = \int p(\chi^2) d\chi^2$ is the indefinite integral such that $dF/d\chi^2 = p(\chi^2)$.
