/** * */ package analyze; //import util.*; /** * Implements different routines to optimize thresholds for * plotting figures. * @author John H. Krantz, Ph.D. * @version 0.1 * */ public class OptimizeThresholds { // private static final int MEAN = Summarize.MEAN; // private static final int STDEV = Summarize.STDEV; // private static final int MAX = Summarize.MAX; // private static final int MIN = Summarize.MIN; private static final int RANGE = Summarize.RANGE; // indexes for the returned threshods public static final int THRESHOLD = 0; public static final int RANGE_THRESHOLD = 1; public static final int DIFF_THRESHOLD = 2; // flags for different wayt to optimize threshosholds public static final int FIT_TO_RANGE = 0; public static final int COMPETATIVE = 1; public static final String [] OPT_TYPE_NAMES = {"Fit to Range", "Competative"}; // private MaxMinTest maxMin = new MaxMinTest(); // empty constructor public OptimizeThresholds(){} // thresholds are proportions of local range. // no theoretical way to determine proportions so // I don't like this one. public double [] fitToRange(double [] sum, double pctThresh, double pctRange, double pctDiff){ // declare the thresh variable double thresh [] = new double [3]; thresh[0] = sum[RANGE]*pctThresh/100.0; thresh[1] = sum[RANGE]*pctRange/100.0; thresh[2] = sum[RANGE]*pctDiff; return thresh; } // in this one if the total difference surrounding the // point is greater thant the diff to range proporition // cutoff, then the thresholds are adjusted so that // thresholds favor difference, otherwise it favors // plotting range. public double [] competRangeDiff(Summarize sum,int x, int y, double maxPos, double maxNeg, double diffToRangeCutOff){ double thresh [] = new double [3]; double range = sum.getPointSummary(y, x)[RANGE]; double totalRange = maxPos+maxNeg; // determine if the range is larger or smaller than // the max or min differences // each threshold is determined independently thresh[THRESHOLD] = 0; thresh[RANGE_THRESHOLD] = totalRange; thresh[DIFF_THRESHOLD] = range*diffToRangeCutOff; return thresh; } }