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

	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.oneSample.confidenceQuantile.*;
import javanpst.tests.oneSample.populationQuantile.*;
import javanpst.data.structures.sequence.NumericSequence;

/**
 * A sample program for testing the hypothesis of a value for a given quantile of a distribution.
 * Value is tested by a Population Quantile procedure. Further, the true quantile value is estimated
 * through a Confidence Quantile procedure 
 *
 * @author Joaqu�n Derrac Rus (jderrac@decsai.ugr.es)
 * @version 1.0
 */
public class QuantileEstimation{

	public static void main(String args []){
	
		/**
		  *  Sample of 15 values from the distribution
		  */
		double sample [] = {690,750,680,700,660,710,720,730,650,670,740,730,660,750,690}; 
		
		//Create data structure
		NumericSequence sequence = new NumericSequence(sample);
		sequence.sort();
		
		//Create test. Hypothesis is quantile=0.75, value=693
		PopulationQuantile test = new PopulationQuantile(sequence,0.75,693);

		//Run procedure
		test.doTest();
		
		//Print results 
		System.out.println("\nResults of Population Quantile estimation:\n"+test.printReport());
		
		//Estimate the true value of the 0.75 quantile, for a sample of 15 elements (confidence level = 0.95)
		ConfidenceQuantile test2 = new ConfidenceQuantile(sequence.size(),0.75,0.95);
		
		//Run procedure
		test2.doTest();
		
		//Print results 
		System.out.println("\nResults of Confidence Quantile estimation:\n"+test2.printReport());
		
		//Get the limits of the estimated confidence interval
		System.out.println("Confidence interval for 0.75 quantile is ["+
		sequence.get((int)test2.getExactLowerLimit()-1)+","+sequence.get((int)test2.getExactUpperLimit()-1)+"]");
			
	}//end-method

}//end-class

 

Ads help maintain this website.