310 likes | 433 Views
Pearson ´s χ 2 Test Modifications for Comparison of Unweighted and Weighted Histograms and Two Weighted Histograms. Nikolai Gagunashvili School of Computing, University of Akureyri, Iceland nikolai@unak.is. Contents. Introduction χ 2 test for comparison two (unweighted) histograms
E N D
Pearson´s χ2 Test Modifications for Comparison of Unweighted and Weighted Histograms and Two Weighted Histograms Nikolai Gagunashvili School of Computing, University of Akureyri, Iceland nikolai@unak.is University of Akureyri, Iceland
Contents • Introduction • χ2test for comparison two (unweighted) histograms • Unweighted and weighted histograms comparison • Two weighted histograms comparison • Numerical example and experiments • Conclusions • References University of Akureyri, Iceland
Introduction A frequently used technique in data analysis is the comparison of histograms. First suggested by Pearson at 1904 theχ2 test of homogeneity is used widely forcomparing usual (unweighted) histograms. The modification of χ2 test for comparisonof weighted and unweighted histograms was proposed at 2005 (see Proceedings of PHYSTAT2005, Oxford 2005). This report develops the ideas presented at the PHYSTAT2005 conference. University of Akureyri, Iceland
χ2test for comparison two (unweighted) histograms Let us consider two histogramswith the same binningand the number of bins equal to r. Let usdenote:The number of events in the ith bin in the first histogram ni The number of events in the ith bin in the second histogram mi The total number of events areequalto for the first histogram, for the second histogram. University of Akureyri, Iceland
χ2test for comparison two (unweighted) histograms The hypothesis of homogeneity:Two histograms represent randomvalues with identical distributions. It is equivalent:There exist r constants, and the probability of belonging to the ithbin for some measured value in both experiments is equal to pi. University of Akureyri, Iceland
χ2 test for comparison two (unweighted) histograms The numberof events in the ith bin is a random variable with a distribution approximatedby a Poisson probability distribution for the first histogram, for the second histogram. If the hypothesisof homogeneity is valid, then the maximum likelihood estimator of University of Akureyri, Iceland
χ2 test for comparison two (unweighted) histograms and then University of Akureyri, Iceland
χ2 test for comparison two (unweighted) histograms The comparison procedure can include an analyses of the residuals which is often helpful in identifying the bins of histogram responsible for a significant overall X2 value. Most convenient for analysis are normalized residuals If hypotheses of homogeneity are valid then residuals riare approximately independent and identically distributed random variables having distribution. University of Akureyri, Iceland
χ2 test for comparison two (unweighted) histograms The application of the χ2 test has restrictions related to the value of the expected frequencies Npi, Mpi, i = 1,…, r. A conservative rule is that all the expectations must be 1 or greater for both histograms. In practical cases when expected frequencies are not known the estimated expected frequencies can be used. University of Akureyri, Iceland
Unweighted and weighted histograms comparison A simple modification of the ideas described above can be used for the comparison of the usual (unweighted) and weighted histograms. Let usdenote:The number of events in the ith bin in the unweighted histogram ni The weight of events in the ith bin of the weighted histogram wi The number of events in the unweighted histogram is equal to The total weight of events in the weighted histogram is equal to University of Akureyri, Iceland
Unweighted and weighted histograms comparison The hypothesis of identity of an unweighted histogram to a weighted histogram: There exist r constants p1,…, pr, such that and the probability of belonging to the ith bin for some measured value is equal to pi for the unweighted histogram and expectation values of weightswiequal to Wpi for the weighted histogram. University of Akureyri, Iceland
Unweighted and weighted histograms comparison The number of events in the ith bin of unweighted histogram is a random variable with distribution approximated by the Poisson probability distribution The weight wi is a random variable with a distribution approximated by the normal probability distribution where σi2is the variance of the weight wi. University of Akureyri, Iceland
Unweighted and weighted histograms comparison If we replace the variance σi2 with estimate si2 (sum of squares of weights of events in the ith bin) and the hypothesis of identity is valid, then the maximum likelihood estimator of pi, i = 1,..,r, is University of Akureyri, Iceland
Unweighted and weighted histograms comparison We may then use the test statistic where and it is plausible that this has approximately a distribution University of Akureyri, Iceland
Unweighted and weighted histograms comparison The variance zi2of the difference between the weight wi and the estimated expectation value of the weight is approximately equal to: The residuals have approximately a normal distribution with mean equal to 0 and standard deviation equal to 1 University of Akureyri, Iceland
Unweighted and weighted histograms comparison Restrictions The minimal expected frequency for an unweighted histogram must be 1. The expected frequencies recommended for the weighted histogram is more than 25. University of Akureyri, Iceland
Two weighted histograms comparison Let us consider two histogramswith the same binningand the number of bins equal to r. Let usdenote: The weight of events in the ith bin of the first histogram w1i The weight of events in the ith bin of the second histogram w2i The total weight of events in the first histogram is equal to The total weight of events in the second histogram is equal to University of Akureyri, Iceland
Two weighted histograms comparison The hypothesis of identity of two weighted histograms: There exist r constants p1,…, pr, such that expectation values of weightsw1iequal to W1pi for the first histogram and expectation values of weightsw2iequal to W2pifor the second histogram University of Akureyri, Iceland
Two weighted histograms comparison Weights in both the histograms are random variables with distributions which can be approximated by a normal probability distribution for the first histogram and by a normal probability distribution for the second histogram Here σ1i2 and σ2i2are the variances of w1i and w2i with estimators s1i2and s2i2 respectively. University of Akureyri, Iceland
Two weighted histograms comparison If the hypothesis of identity is valid, then the maximum likelihood and Least Square Method estimator of pi , 1,…, r, is University of Akureyri, Iceland
Two weighted histograms comparison We may then use the test statistic and it is plausible that this has approximately a distribution. University of Akureyri, Iceland
Two weighted histograms comparison The normalized residuals where have approximately a normal distribution with mean equal to 0 and standard deviation 1. University of Akureyri, Iceland
Two weighted histograms comparison Restriction A recommended minimal expected frequency is equal to 25 for the proposed test. University of Akureyri, Iceland
Numerical example and experiments The method described herein is now illustrated with an example. We take a distribution defined on the interval [4; 16]. Events distributed according to the formula are simulated to create the unweighted histogram. Uniformly distributed events are simulated for the weighted histogram with weights calculated by formula. Each histogram has the same number of bins: 20. University of Akureyri, Iceland
An example of comparison of the unweighted histogram with 200 events and the weighted histogram with 500 events weighted histogram unweighted histogram residuals Q-Q plot University of Akureyri, Iceland
Numerical example and experiments The value of the test statistic X2 is equal to 21.09 with p-value equal to 0.33, therefore the hypothesis of identity of the two histograms can be accepted. The behavior of the normalized residuals plot and the normal Q-Q plot of residuals are regular and we cannot identify the outliers or bins with a big influence on X2. University of Akureyri, Iceland
Chi-square Q-Q plots of X2 statistics for two unweighted histograms with different minimal expected frequencies. University of Akureyri, Iceland
Chi-square Q-Q plots of X2 statistics for unweighted and weighted histograms with different minimal expected frequencies. University of Akureyri, Iceland
Chi-square Q-Q plots of X2 statistics for two weighted histograms with different minimal expected frequencies. University of Akureyri, Iceland
Conclusions A test for comparing the usual (unweighted) histogram and the weighted histogram was proposed. A test for comparing two weighted histograms was proposed. In both cases formulas for normalized residuals were presented that can be useful for the identifications of bins that are outliers, or bins that have a big influence on X2. The proposed in this paper approach can be generalized for a comparison of several unweighted and weighted histograms or just weighted histograms. The test statistic has approximately a distribution for s histograms with r bins. University of Akureyri, Iceland
[7] Gagunashvili, N., Comparison of weighted and unweighted histograms, arXiv:physics/0605123, 2006 University of Akureyri, Iceland