/***********************************************************************

	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.examples;

import javanpst.tests.twoSample.medianTest.*;
import javanpst.tests.twoSample.controlMedianTest.*;

import javanpst.data.structures.dataTable.DataTable;

/**
 * An example testing differences between two samples through
 * two test based on medians:  The median test (using the combined 
 * median sample) and the control median test (using the opposite sample 
 * median)
 *
 * @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
 * @version 1.0
 */
public class TestMedian{

	public static void main(String args []){
	
		/**
		 * Two samples from two independent populations
		 */
		double samples [][] = {{3,1},
								{4,2},
								{9,5},
								{10,7},
								{-1,8}
								};

		//Data is formatted
		DataTable data = new DataTable(samples);
		
		//-1 is a null value (e.g. sample 1 has 4 values)
		data.setNull(4,0);
	
		//Create tests
		MedianTest median = new MedianTest(data);
		ControlMedianTest control = new ControlMedianTest(data);
	
		//Run median test
		median.doTest();
		
		//Print results of the test
		System.out.println("Results of Median test:\n"+median.printReport());
		
		System.out.println();
		System.out.println("*******************");
		System.out.println("*******************");
		System.out.println("*******************");
		System.out.println();
		
		//Run control median test
		control.doTest();
		
		//Print results of the test
		System.out.println("Results of Control Median test:\n"+control.printReport());
			
	}//end-method

}//end-class

 

Ads help maintain this website.