当前位置: 首页>>代码示例>>Java>>正文


Java DescriptiveStatistics.getPercentile方法代码示例

本文整理汇总了Java中org.apache.commons.math.stat.descriptive.DescriptiveStatistics.getPercentile方法的典型用法代码示例。如果您正苦于以下问题:Java DescriptiveStatistics.getPercentile方法的具体用法?Java DescriptiveStatistics.getPercentile怎么用?Java DescriptiveStatistics.getPercentile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math.stat.descriptive.DescriptiveStatistics的用法示例。


在下文中一共展示了DescriptiveStatistics.getPercentile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: winsor2

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**Winsorise vector x. Adapted from https://www.r-bloggers.com/winsorization/.
 * */
public static List<Float> winsor2(List<Float> x, double multiple) {
			/*
			winsor2<- function (x, multiple=3)
			{
			   med <- median(x)
			   y <- x - med
			   sc <- mad(y, center=0) * multiple
			   y[ y > sc ] <- sc
			   y[ y < -sc ] <- -sc
			   y + med
			}
			*/
	if(multiple <= 0){
		throw new ArithmeticException(); 
	}
	DescriptiveStatistics stats = new DescriptiveStatistics();
	for(float z : x){
		stats.addValue(z);
	}
	float median = (float)stats.getPercentile(50);
	List<Float> y= new ArrayList<Float>(x);
	for(int i= 0; i < x.size(); i++){
		y.set(i, x.get(i) - median);
	}
	float sc= (float) (Utils.medianAbsoluteDeviation(y, 0) * multiple);
	for(int i= 0; i < y.size(); i++){
		if(y.get(i) > sc){
			y.set(i, sc);
		}
		else if(y.get(i) < -sc){
			y.set(i, -sc);
		}
		y.set(i, y.get(i) + median);
	}
	return y;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:39,代码来源:Utils.java

示例2: medianAbsoluteDeviation

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/** Translated from R function mad(x, center, constant= 1.4826, na.rm= FALSE, low= FALSE, high= FALSE). 
 * */
private static float medianAbsoluteDeviation(List<Float> x, float center) {
	DescriptiveStatistics stats = new DescriptiveStatistics();
	for(int i= 0; i < x.size(); i++){
		stats.addValue(Math.abs(x.get(i) - center));
	}
	float median= (float)stats.getPercentile(50);
	return (float)1.4826 * median;
}
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:11,代码来源:Utils.java

示例3: AnalysisResultsModel

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public AnalysisResultsModel(ArrayList<Double> firesPerCenturyPerSim, SegmentModel segment, int numberOfSamples) {
	
	this.segment = segment;
	this.numberOfSamples = numberOfSamples;
	
	// Generate Apache Commons descriptive statistics
	stats = new DescriptiveStatistics();
	for (Double val : firesPerCenturyPerSim)
	{
		stats.addValue(val);
	}
	
	meanEventsPerCentury = stats.getMean();
	std = stats.getStandardDeviation();
	median = stats.getPercentile(50);
	CI95 = STDEV_MULTIPLIER_FOR_95 * std;
	CI99 = STDEV_MULTIPLIER_FOR_99 * std;
	
	// Generate Weibull stats
	Weibull weibull = new Weibull(firesPerCenturyPerSim);
	weibullMean = weibull.getMean();
	weibullMedian = weibull.getMedian();
	
	// TODO Elena to check
	weibullCI95Lower = weibull.getExceedencePercentile(5.0);
	weibullCI95Upper = weibull.getExceedencePercentile(95.0);
	
	weibullCI99 = weibull.getExceedencePercentile(99.0) - weibullMedian;
}
 
开发者ID:petebrew,项目名称:fhaes,代码行数:30,代码来源:AnalysisResultsModel.java

示例4: getNumberOfBins

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
 * Get the histogram bin size.
 *
 * @param values the values to calculate the bin size for
 * @return the histogram bin size
 */
private int getNumberOfBins(double[] values) {

    // @TODO: this seems to always return very low number of bins??
    // @TODO: when working this code should be moved out of this class!!
    double minValue = Double.MAX_VALUE;
    double maxValue = Double.MIN_VALUE;

    // Get a DescriptiveStatistics instance
    DescriptiveStatistics stats = new DescriptiveStatistics();
    // Add the data from the array
    for (int i = 0; i < values.length; i++) {
        stats.addValue(values[i]);

        if (values[i] > maxValue) {
            maxValue = values[i];
        }
        if (values[i] < minValue) {
            minValue = values[i];
        }
    }

    double q1 = stats.getPercentile(25);
    double q3 = stats.getPercentile(75);
    double range = Math.abs(maxValue - minValue);

    if (q3 - q1 == 0 || values.length == 0) {
        return 10;
    }

    int freedmanDiaconisValue = (int) Math.ceil((Math.pow(values.length, 1 / 3) * range) / (2 * (q3 - q1)));
    //int freedmanDiaconisValue = (int) Math.ceil((Math.pow(values.length, 1 / 3) * range)/(3.5*stats.getStandardDeviation())); // scott
    //int freedmanDiaconisValue = (int) Math.ceil(Math.log(2*values.length) + 1); // sturges

    if (freedmanDiaconisValue == 0 || freedmanDiaconisValue < 10) {
        return 10;
    }

    return freedmanDiaconisValue;
}
 
开发者ID:compomics,项目名称:compomics-utilities,代码行数:46,代码来源:XYPlottingDialog.java

示例5: getBin_spectrum

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
public double[] getBin_spectrum(int shift) {
    ArrayList<Double> bin_spec_al = new ArrayList<Double>();
    double binSize = (fragment_tolerance * 2),
            upperLimit = max_value + 0.00001;
    for (double lowerLimit = min_value; lowerLimit < upperLimit; lowerLimit = lowerLimit + binSize) {
        double tmp_intensity_bin = 0;
        DescriptiveStatistics obj = new DescriptiveStatistics();
        for (Peak p : peakList) {
            double mz = p.getMz() + shift;
            if (mz >= lowerLimit && mz < lowerLimit + binSize) {
                obj.addValue(p.intensity);
            }
        }
        if (obj.getN() > 0) {
            if (intensities_sum_or_mean_or_median == 0) {
                tmp_intensity_bin = obj.getSum();
            } else if (intensities_sum_or_mean_or_median == 1) {
                tmp_intensity_bin = obj.getMean();
            } else if (intensities_sum_or_mean_or_median == 2) {
                tmp_intensity_bin = obj.getPercentile(50);
            }
        }
        // put every bin_pectrum
        bin_spec_al.add(tmp_intensity_bin);
    }
    // convert an arraylist to double array
    // initiate size of array
    bin_size = bin_spec_al.size();
    double[] bin_spectrum = new double[bin_spec_al.size()];
    for (int i = 0; i < bin_spec_al.size(); i++) {
        bin_spectrum[i] = bin_spec_al.get(i);
    }
    return bin_spectrum;
}
 
开发者ID:compomics,项目名称:spectrum_similarity,代码行数:35,代码来源:BinMSnSpectrum.java

示例6: prepareBinSpectra

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
private ArrayList<double[]> prepareBinSpectra() {
    // first prepare bin-spectrum to be filled with zero
    int size = (2 * correctionFactor) + 1;

    ArrayList<double[]> shiftedSpectra = new ArrayList<double[]>(size);
    for (int i = 0; i < size; i++) {
        double[] shiftedSpectrum = new double[bin_size];
        shiftedSpectra.add(shiftedSpectrum);
    }
    // now fill each bin spectrum with correct mz values.
    double binSize = (fragment_tolerance * 2),
            upperLimit = max_value + 0.00001;
    int current_index = 0;
    for (double lowerLimit = min_value + correctionFactor; lowerLimit < upperLimit - correctionFactor; lowerLimit = lowerLimit + binSize) {
        double tmp_intensity_bin = 0;
        DescriptiveStatistics obj = new DescriptiveStatistics();
        for (Peak p : peakList) {
            double mz = p.getMz();
            if (mz >= lowerLimit && mz < lowerLimit + binSize) {
                obj.addValue(p.intensity);
            }
        }
        if (obj.getN() > 0) {
            if (intensities_sum_or_mean_or_median == 0) {
                tmp_intensity_bin = obj.getSum();
            } else if (intensities_sum_or_mean_or_median == 1) {
                tmp_intensity_bin = obj.getMean();
            } else if (intensities_sum_or_mean_or_median == 2) {
                tmp_intensity_bin = obj.getPercentile(50);
            }
        }
        // put every bin_pectrum            
        int filling_index = current_index;
        // check every bin spectrum            
        for (double[] shifted : shiftedSpectra) {
            shifted[filling_index] = tmp_intensity_bin;
            filling_index++;
        }
        current_index++;
    }
    return shiftedSpectra;
}
 
开发者ID:compomics,项目名称:spectrum_similarity,代码行数:43,代码来源:BinMSnSpectrum.java

示例7: getSkeletonCategoryFromPercentiles

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
private Integer getSkeletonCategoryFromPercentiles(Integer value, DescriptiveStatistics windowStats)
{
	Integer skeletonCategory = 0;
	// Calculate skeleton category
	if(value == (int) windowStats.getMin())
	{
		skeletonCategory = 10;
	}
	else if(value < windowStats.getPercentile(10))
	{
		skeletonCategory = 9;
	}
	else if(value < windowStats.getPercentile(15))
	{
		skeletonCategory = 8;
	}
	else if(value < windowStats.getPercentile(20))
	{
		skeletonCategory = 7;
	}
	else if(value < windowStats.getPercentile(25))
	{
		skeletonCategory = 6;
	}
	else if(value < windowStats.getPercentile(30))
	{
		skeletonCategory = 5;
	}
	else if(value < windowStats.getPercentile(35))
	{
		skeletonCategory = 4;
	}
	else if(value < windowStats.getPercentile(40))
	{
		skeletonCategory = 3;
	}
	else if(value < windowStats.getPercentile(45))
	{
		skeletonCategory = 2;
	}
	else if(value < windowStats.getPercentile(50))
	{
		skeletonCategory = 1;				
	}
	
	return skeletonCategory;
}
 
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:48,代码来源:SkeletonPlot.java

示例8: DescriptiveStatistics

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics; //导入方法依赖的package包/类
/**
 * Filter the components to find likely letter candidates.
 * 
 * @param components
 *            the components to filter
 * @param swt
 *            the swt image
 * @param image
 *            the original image
 * @return the potential letter candidates
 */
protected static List<LetterCandidate>
		findLetters(List<ConnectedComponent> components, FImage swt, FImage image, SWTTextDetector.Options options)
{
	final List<LetterCandidate> output = new ArrayList<LetterCandidate>();

	final DescriptiveStatistics stats = new DescriptiveStatistics();
	for (final ConnectedComponent cc : components) {
		// additional check for small area - speeds processing...
		if (cc.pixels.size() < options.minArea)
			continue;

		computeStats(stats, cc, swt);

		final double mean = stats.getMean();
		final double variance = stats.getVariance();
		final double median = stats.getPercentile(50);

		// test variance of stroke width
		if (variance > options.letterVarianceMean * mean)
			continue;

		final Rectangle bb = cc.calculateRegularBoundingBox();

		// test aspect ratio
		final double aspect = Math.max(bb.width, bb.height) / Math.min(bb.width, bb.height);
		if (aspect > options.maxAspectRatio)
			continue;

		// test diameter
		final float diameter = Math.max(bb.width, bb.height);
		if (diameter / median > options.maxDiameterStrokeRatio)
			continue;

		// check occlusion
		int overlapping = 0;
		for (final ConnectedComponent cc2 : components) {
			if (cc2 == cc)
				continue;
			final Rectangle bb2 = cc2.calculateRegularBoundingBox();
			if (bb2.intersectionArea(bb) > 0)
				overlapping++;
		}
		if (overlapping > options.maxNumOverlappingBoxes)
			continue;

		// check height
		if (bb.height < options.minHeight || bb.height > options.maxHeight)
			continue;

		output.add(new LetterCandidate(cc, (float) median, image));
	}

	return output;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:66,代码来源:LetterCandidate.java


注:本文中的org.apache.commons.math.stat.descriptive.DescriptiveStatistics.getPercentile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。