/*
* Class ProbabilityPlot
*
* USAGE: Probability Plots
*
* WRITTEN BY: Dr Michael Thomas Flanagan
*
* DATE: 29-30 September 2008, 1-5 October 2008, 13-24 October 2009, 2 November 2010, 8 December 2010
* 7 December 2011, 4 January 2012
*
* DOCUMENTATION:
* See Michael Thomas Flanagan's Java library on-line web page:
* http://www.ee.ucl.ac.uk/~mflanaga/java/ProbabilityPlot.html
* http://www.ee.ucl.ac.uk/~mflanaga/java/
*
* Copyright (c) 2009 Michael Thomas Flanagan
*
* PERMISSION TO COPY:
*
* Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee,
* provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies
* and associated documentation or publications.
*
* Redistributions of the source code of this source code, or parts of the source codes, must retain the above copyright notice, this list of conditions
* and the following disclaimer and requires written permission from the Michael Thomas Flanagan:
*
* Redistribution in binary form of all or parts of this class must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission from the Michael Thomas Flanagan:
*
* Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose.
* Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software
* or its derivatives.
*
***************************************************************************************/
package flanagan.analysis;
import java.util.*;
import java.math.*;
import flanagan.math.*;
import flanagan.plot.PlotGraph;
import flanagan.interpolation.CubicSpline;
import flanagan.io.PrintToScreen;
public class ProbabilityPlot{
// INSTANCE VARIABLES
private double[] array = null; // array of data
private Stat arrayAsStat = null; // array of data as Stat
private double[] sortedData = null; // data sorted into ascending order
private double[] weights = null; // weights
private boolean weighted = false; // = true if weighted regression to be performed
private double mean = Double.NaN; // array mean
private double standardDeviation = Double.NaN; // array standard deviation
private double minimum = Double.NaN; // array minimum
private double maximum = Double.NaN; // array maximum
private double range = Double.NaN; // array range
private double halfWidth = Double.NaN; // rough estimate of peak width at half peak height
private double peakPoint = Double.NaN; // rough estimate of peak position
private int numberOfDataPoints = 0; // number of data points
private double dataOffset = 0.0; // data offset if data shifted
private boolean dataShifted = false; // = true if data offset
private double[] initialEstimates = null; // initial estimates used in last call to a probability plot method
private int lastMethod = 0; // Last probability plot method called
// 0 Gaussian
// 1 Weibull (three parameter)
// 2 Exponential
// 3 Rayleigh
// 4 Pareto
// 5 Gumbel (minimum order statistic)
// 6 Gumbel (maximum order statistic)
// 7 Frechet
// 8 Logistic
// 9 Lorentzian // TO BE ADDED
// 10 Log-Normal (three parameter) // TO BE ADDED
// 11 Log-Normal (two parameter // TO BE ADDED
// 12 Weibull (two parameter)
// 13 Weibull (standard)
// 14 Standard Gaussian
// 15 F-distribution
private boolean supressPlot = false; // set to true to supress the display of the plot
private int gaussianNumberOfParameters = 2; // number of Gaussian parameters
private double[] gaussianOrderMedians = null; // Gaussian order statistic medians
private double[] gaussianParam = null; // Gaussian parameters obtained by the minimization procedure
private double[] gaussianParamErrors = null; // estimates of the errors of the Gaussian parameters obtained by the minimization procedure
private double gaussianSumOfSquares = Double.NaN; // sum of squares at Gaussian minimum
private double gaussianUnweightedSumOfSquares = Double.NaN; // unweighted sum of squares at Gaussian minimum
private double[] gaussianLine = null; // Gaussian probability plot gradient and intercept
private double[] gaussianLineErrors = null; // estimated errors of the Gaussian probability plot gradient and intercept
private double gaussianCorrCoeff = Double.NaN; // Gaussian correlation coefficient of the probability plot
private boolean gaussianDone = false; // = true after Gaussian probability plot drawn
private int gaussianStandardNumberOfParameters = 0; // number of Standard Gauss parameters
private double[] gaussianStandardOrderMedians = null; // Standard Gauss order statistic medians
private double gaussianStandardSumOfSquares = Double.NaN; // sum of squares at Standard Gauss minimum
private double[] gaussianStandardLine = null; // Standard Gauss probability plot gradient and intercept
private double[] gaussianStandardLineErrors = null; // estimated errors of the Standard Gauss probability plot gradient and intercept
private double gaussianStandardCorrCoeff = Double.NaN; // Standard Gauss correlation coefficient of the probability plot
private boolean gaussianStandardDone = false; // = true after Standard Gauss probability plot drawn
private int exponentialNumberOfParameters = 2; // number of Exponential parameters
private double[] exponentialOrderMedians = null; // Exponential order statistic medians
private double[] exponentialParam = null; // Exponential parameters obtained by the minimization procedure
private double[] exponentialParamErrors = null; // estimates of the errors of the Exponential parameters obtained by the minimization procedure
private double exponentialSumOfSquares = Double.NaN; // sum of squares at Exponential minimum
private double[] exponentialLine = null; // Exponential probability plot gradient and intercept
private double[] exponentialLineErrors = null; // estimated errors of the Exponential probability plot gradient and intercept
private double exponentialCorrCoeff = Double.NaN; // Exponential correlation coefficient of the probability plot
private boolean exponentialDone = false; // = true after Exponential probability plot drawn
private int fDistributionNumberOfParameters = 0; // number of F-distribution parameters
private double[] fDistributionOrderMedians = null; // F-distribution order statistic medians
private double fDistributionSumOfSquares = Double.NaN; // sum of squares at F-distribution minimum
private double[] fDistributionLine = null; // F-distribution probability plot gradient and intercept
private double[] fDistributionLineErrors = null; // estimated errors of the F-distribution probability plot gradient and intercept
private double fDistributionCorrCoeff = Double.NaN; // F-distribution correlation coefficient of the probability plot
private boolean fDistributionDone = false; // = true after F-distribution probability plot drawn
private int frechetNumberOfParameters = 3; // number of Frechet parameters
private double[] frechetOrderMedians = null; // Frechet order statistic medians
private double[] frechetParam = null; // Frechet parameters obtained by the minimization procedure
private double[] frechetParamErrors = null; // estimates of the errors of the Frechet parameters obtained by the minimization procedure
private double frechetSumOfSquares = Double.NaN; // sum of squares at Frechet minimum
private double[] frechetLine = null; // Frechet probability plot gradient and intercept
private double[] frechetLineErrors = null; // estimated errors of the Frechet probability plot gradient and intercept
private double frechetCorrCoeff = Double.NaN; // Frechet correlation coefficient of the probability plot
private boolean frechetDone = false; // = true after Frechet probability plot drawn
private int gumbelMinNumberOfParameters = 3; // number of Gumbel (minimum order statistic) parameters
private double[] gumbelMinOrderMedians = null; // Gumbel (minimum order statistic) order statistic medians
private double[] gumbelMinParam = null; // Gumbel (minimum order statistic) parameters obtained by the minimization procedure
private double[] gumbelMinParamErrors = null; // estimates of the errors of the Gumbel (minimum order statistic) parameters obtained by the minimization procedure
private double gumbelMinSumOfSquares = Double.NaN; // sum of squares at Gumbel (minimum order statistic) minimum
private double[] gumbelMinLine = null; // Gumbel (minimum order statistic) probability plot gradient and intercept
private double[] gumbelMinLineErrors = null; // estimated errors of the Gumbel (minimum order statistic) probability plot gradient and intercept
private double gumbelMinCorrCoeff = Double.NaN; // Gumbel (minimum order statistic) correlation coefficient of the probability plot
private boolean gumbelMinDone = false; // = true after Gumbel (minimum order statistic) probability plot drawn
private int gumbelMaxNumberOfParameters = 3; // number of Gumbel (maximum order statistic) parameters
private double[] gumbelMaxOrderMedians = null; // Gumbel (maximum order statistic) order statistic medians
private double[] gumbelMaxParam = null; // Gumbel (maximum order statistic) parameters obtained by the maximization procedure
private double[] gumbelMaxParamErrors = null; // estimates of the errors of the Gumbel (maximum order statistic) parameters obtained by the maximization procedure
private double gumbelMaxSumOfSquares = Double.NaN; // sum of squares at Gumbel (maximum order statistic) maximum
private double[] gumbelMaxLine = null; // Gumbel (maximum order statistic) probability plot gradient and intercept
private double[] gumbelMaxLineErrors = null; // estimated errors of the Gumbel (maximum order statistic) probability plot gradient and intercept
private double gumbelMaxCorrCoeff = Double.NaN; // Gumbel (maximum order statistic) correlation coefficient of the probability plot
private boolean gumbelMaxDone = false; // = true after Gumbel (maximum order statistic) probability plot drawn
private int logisticNumberOfParameters = 3; // number of Logistic parameters
private double[] logisticOrderMedians = null; // Logistic order statistic medians
private double[] logisticParam = null; // Logistic parameters obtained by the minimization procedure
private double[] logisticParamErrors = null; // estimates of the errors of the Logistic parameters obtained by the minimization procedure
private double logisticSumOfSquares = Double.NaN; // sum of squares at Logistic minimum
private double[] logisticLine = null; // Logistic probability plot gradient and intercept
private double[] logisticLineErrors = null; // estimated errors of the Logistic probability plot gradient and intercept
private double logisticCorrCoeff = Double.NaN; // Logistic correlation coefficient of the probability plot
private boolean logisticDone = false; // = true after Logistic probability plot drawn
private int paretoNumberOfParameters = 2; // number of Pareto parameters
private double[] paretoOrderMedians = null; // Pareto order statistic medians
private double[] paretoParam = null; // Pareto parameters obtained by the minimization procedure
private double[] paretoParamErrors = null; // estimates of the errors of the Pareto parameters obtained by the minimization procedure
private double paretoSumOfSquares = Double.NaN; // sum of squares at Pareto minimum
private double[] paretoLine = null; // Pareto probability plot gradient and intercept
private double[] paretoLineErrors = null; // estimated errors of the Pareto probability plot gradient and intercept
private double paretoCorrCoeff = Double.NaN; // Pareto correlation coefficient of the probability plot
private boolean paretoDone = false; // = true after Pareto probability plot drawn
private int rayleighNumberOfParameters = 2; // number of Rayleigh parameters
private double[] rayleighOrderMedians = null; // Rayleigh order statistic medians
private double[] rayleighParam = null; // Rayleigh parameters obtained by the minimization procedure
private double[] rayleighParamErrors = null; // estimates of the errors of the Rayleigh parameters obtained by the minimization procedure
private double rayleighSumOfSquares = Double.NaN; // sum of squares at Rayleigh minimum
private double[] rayleighLine = null; // Rayleigh probability plot gradient and intercept
private double[] rayleighLineErrors = null; // estimated errors of the Rayleigh probability plot gradient and intercept
private double rayleighCorrCoeff = Double.NaN; // Rayleigh correlation coefficient of the probability plot
private boolean rayleighDone = false; // = true after Rayleigh probability plot drawn
private int weibullNumberOfParameters = 3; // number of Three Parameter Weibull parameters
private double[] weibullOrderMedians = null; // Three Parameter Weibull order statistic medians
private double[] weibullParam = null; // Three Parameter Weibull parameters obtained by the minimization procedure
private double[] weibullParamErrors = null; // estimates of the errors of the Three Parameter Weibull parameters obtained by the minimization procedure
private double weibullSumOfSquares = Double.NaN; // sum of squares at Three Parameter Weibull minimum
private double[] weibullLine = null; // Three Parameter Weibull probability plot gradient and intercept
private double[] weibullLineErrors = null; // estimated errors of the Three Parameter Weibull probability plot gradient and intercept
private double weibullCorrCoeff = Double.NaN; // Three Parameter Weibull correlation coefficient of the probability plot
private boolean weibullDone = false; // = true after Three Parameter Weibull probability plot drawn
private int weibullTwoParNumberOfParameters = 2; // number of Two Parameter Weibull parameters
private double[] weibullTwoParOrderMedians = null; // Two Parameter Weibull order statistic medians
private double[] weibullTwoParParam = null; // Two Parameter Weibull parameters obtained by the minimization procedure
private double[] weibullTwoParParamErrors = null; // estimates of the errors of the Two Parameter Weibull parameters obtained by the minimization procedure
private double weibullTwoParSumOfSquares = Double.NaN; // sum of squares at Two Parameter Weibull minimum
private double[] weibullTwoParLine = null; // Two Parameter Weibull probability plot gradient and intercept
private double[] weibullTwoParLineErrors = null; // estimated errors of the Two Parameter Weibull probability plot gradient and intercept
private double weibullTwoParCorrCoeff = Double.NaN; // Two Parameter Weibull correlation coefficient of the probability plot
private boolean weibullTwoParDone = false; // = true after Two Parameter Weibull probability plot drawn
private int weibullStandardNumberOfParameters = 1; // number of Standard Weibull parameters
private double[] weibullStandardOrderMedians = null; // Standard Weibull order statistic medians
private double[] weibullStandardParam = null; // Standard Weibull parameters obtained by the minimization procedure
private double[] weibullStandardParamErrors = null; // estimates of the errors of the Standard Weibull parameters obtained by the minimization procedure
private double weibullStandardSumOfSquares = Double.NaN;// sum of squares at Standard Weibull minimum
private double[] weibullStandardLine = null; // Standard Weibull probability plot gradient and intercept
private double[] weibullStandardLineErrors = null; // estimated errors of the Standard Weibull probability plot gradient and intercept
private double weibullStandardCorrCoeff = Double.NaN; // Standard Weibull correlation coefficient of the probability plot
private boolean weibullStandardDone = false; // = true after Standard Weibull probability plot drawn
private boolean probPlotDone = false; // = true after any probability plot drawn
private double delta = 1e-3; // step fraction in numerical differentiation
private boolean nFactorOptionI = false; // = true variance, covariance and standard deviation denominator = n // = false varaiance, covariance and standard deviation denominator = n-1
private boolean nFactorReset = false; // = true when instance method resetting the denominator is called
// CONSTRUCTORS
public ProbabilityPlot(double[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Double[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(float[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Float[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(long[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Long[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(int[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Integer[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(short[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Short[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(byte[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Byte[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(BigDecimal[] xx){
this.arrayAsStat = new Stat(xx);
this.initialize();
}
public ProbabilityPlot(BigInteger[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Object[] xx){
this.arrayAsStat = new Stat(xx);
this.array = this.arrayAsStat.array();
this.initialize();
}
public ProbabilityPlot(Vector
Ads help maintain this website.