/***********************************************************************
This file is part of JavaNPST, a Java library of NonParametric
Statistical Tests.
Copyright (C) 2011
J. Derrac (jderrac@decsai.ugr.es)
S. Garcia (sglopez@ujaen.es)
F. Herrera (herrera@decsai.ugr.es)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
**********************************************************************/
package javanpst.tests.equality.extendedMedianTest;
import java.util.Arrays;
import javanpst.data.structures.dataTable.DataTable;
import javanpst.distributions.common.continuous.ChiSquareDistribution;
import javanpst.tests.StatisticalTest;
/**
* A extension of the median test for k independent samples
*
* This test can be applied to test the null hypotheses of equal medians
* between populations. P-values are computed through a chi-square distribution
* approximation.
*
* All samples must have the same number of elements.
*
* @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
* @version 1.0
*/
public class ExtendedMedianTest extends StatisticalTest{
/**
* Data to analyze
*/
private DataTable data;
/**
* Populations samples
*/
private double samples [][];
/**
* Total number of elements
*/
private double N;
/**
* Position of the samples' values with respect to median
*/
private double position [][];
/**
* Median value of the samples
*/
private double median;
/**
* Array with all the values of the combined sample
*/
private double combined[];
/**
* Q statistic
*/
private double Q;
/**
* Q statistic improved to approximate to a chi-square distribution
*/
private double improvedQ;
/**
* P-value computed
*/
private double pValue;
/**
* Default builder
*/
public ExtendedMedianTest(){
setReportFormat();
clearData();
}//end-method
/**
* Clears the data stored in the test
*/
public void clearData(){
data=new DataTable();
performed=false;
dataReady=false;
Q=0.0;
improvedQ=0.0;
median=0;
samples=null;
position=null;
pValue=-1.0;
}//end-method
/**
* Builder. Load data to test.
*
* @param newData data to test.
*/
public ExtendedMedianTest(DataTable newData){
setReportFormat();
data=DataTable.newInstance(newData);
if(data.getColumns()<3){
System.out.println("Extended median test only can be employed with more than two samples");
clearData();
return;
}
for(int i=0;i0){
System.out.println("No null values allowed in this test.");
clearData();
return;
}
}
samples=new double[data.getRows()][data.getColumns()];
combined=new double[data.getRows()*data.getColumns()];
position=new double[2][data.getColumns()];
Arrays.fill(position[0], 0.0);
Arrays.fill(position[1], 0.0);
for(int i=0;i0){
System.out.println("No null values allowed in this test.");
clearData();
return;
}
}
samples=new double[data.getRows()][data.getColumns()];
combined=new double[data.getRows()*data.getColumns()];
position=new double[2][data.getColumns()];
Arrays.fill(position[0], 0.0);
Arrays.fill(position[1], 0.0);
for(int i=0;i
Ads help maintain this website.