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


Java StatUtils.percentile方法代码示例

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


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

示例1: CufflinksDataSource

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
public CufflinksDataSource(List<? extends LocusScore> valueList, Genome genome) {

        chrAliasMap = new HashMap<String, String>();
        values = new HashMap<String, List<LocusScore>>();

        DownsampledDoubleArrayList sampledData = sampleValues(valueList, genome);

        // Sort
        for (List<LocusScore> chrValues : values.values()) {
            FeatureUtils.sortFeatureList(chrValues);
        }

        double[] sd = sampledData.toArray();
        if (sd.length > 0) {
            dataMin = Math.min(0, StatUtils.percentile(sd, 5));
            dataMax = StatUtils.percentile(sd, 95);
        } else {
            dataMin = 0;
            dataMax = 100;
        }

        calculateWholeGenomeScores(genome);
    }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:24,代码来源:CufflinksDataSource.java

示例2: computePercentiles

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private void computePercentiles() {
    if (values != null) {
        double[] valueArray = values.toArray();
        for (WindowFunction wf : quantileFunctions) {
            double p = this.getPercentile(wf);
            if (p > 0) {
                float v = (float) StatUtils.percentile(valueArray, p);
                if (Float.isInfinite(v)) {
                    log.error("Infinite percentile (" + wf + ")");
                } else {
                    List<PercentileValue> pList = percentiles.get(wf);
                    if (pList == null) {
                        pList = new ArrayList();
                        percentiles.put(wf, pList);
                    }
                    pList.add(new PercentileValue(valueArray.length, v));
                }
            }
        }
    }

}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:23,代码来源:ListAccumulator.java

示例3: computePercentiles

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private void computePercentiles() {

        // Statistics, other attributes
        DoubleArrayList flattenedDataList = new DoubleArrayList(matrix.getColumnDimension() * matrix.getRowDimension());
        double min = 1;
        double max = -1;
        for (int i = 0; i < matrix.getRowDimension(); i++) {
            for (int j = 0; j < matrix.getColumnDimension(); j++) {
                double value = matrix.getEntry(i, j);
                if (!Double.isNaN(value) && value != 1) {
                    min = value < min ? value : min;
                    max = value > max ? value : max;
                    flattenedDataList.add(value);
                }
            }
        }

        // Stats
        double[] flattenedData = flattenedDataList.toArray();
        lowerValue = (float) StatUtils.percentile(flattenedData, 5);
        upperValue = (float) StatUtils.percentile(flattenedData, 95);
        System.out.println(lowerValue + "  " + upperValue);

    }
 
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:25,代码来源:RealMatrixWrapper.java

示例4: computePercentiles

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private void computePercentiles() {

        // Statistics, other attributes
        DoubleArrayList flattenedDataList = new DoubleArrayList(data.length);

        for (float value : data) {
            if (!Float.isNaN(value) && value != 1) {
                flattenedDataList.add(value);
            }
        }

        // Stats
        double[] flattenedData = flattenedDataList.toArray();
        lowerValue = (float) StatUtils.percentile(flattenedData, 5);
        upperValue = (float) StatUtils.percentile(flattenedData, 95);
    }
 
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:17,代码来源:SymmetricMatrix.java

示例5: initDataRange

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private void initDataRange() {
    MatrixZoomData zd;
    try {
        zd = hic.getZd();
    } catch (Exception e) {
        return;
    }

    if (zd != null) {
        int chrIdx = zd.getChr1Idx();
        HiCZoom zoom = zd.getZoom();
        NormalizationVector nv = hic.getDataset().getNormalizationVector(chrIdx, zoom, normalizationType);
        if (nv == null) {
            setDataRange(new DataRange(0, 1));
        } else {
            double max = StatUtils.percentile(nv.getData(), 95);
            setDataRange(new DataRange(0, (float) max));
        }

    }
}
 
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:22,代码来源:HiCCoverageDataSource.java

示例6: computePercentile

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private float computePercentile(List<Block> blocks, double p) {


        DoubleArrayList dal = new DoubleArrayList(10000);
        if (blocks != null) {
            for (Block b : blocks) {
                for (ContactRecord rec : b.getContactRecords()) {
                    // Filter diagonal
                    if (Math.abs(rec.getBinX() - rec.getBinY()) > 1) {
                        float val = rec.getCounts();  // view with average multiplied

                        dal.add(val);
                    }
                }
            }
        }
        return dal.size() == 0 ? 1 : (float) StatUtils.percentile(dal.toArray(), p);
    }
 
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:19,代码来源:HeatmapRenderer.java

示例7: finish

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
public void finish() {

        if (isFinished) {
            return;
        }

        if (windowFunction == WindowFunction.mean) {
            value = Float.isNaN(sum) ? Float.NaN : sum / basesCovered;
        } else if (valueList != null) {
            if (valueList.size() == 0) {
                value = Float.NaN;
            } else if (valueList.size() == 1) {
                value = (float) valueList.get(0);
            } else {
                double[] valueArray = valueList.toArray();
                double p = this.getPercentile(windowFunction);
                if (p > 0) {
                    value = (float) StatUtils.percentile(valueArray, p);
                } else {
                    value = Float.NaN;
                }
            }

        }

        valueList = null;
        isFinished = true;

    }
 
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:30,代码来源:Accumulator.java

示例8: parsingComplete

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
protected void parsingComplete() {
    dataset.sort(unsortedChromosomes);
    dataset.setLongestFeatureMap(longestFeatureMap);

    double[] sd = sampledData.toArray();
    double percent10 = StatUtils.percentile(sd, 10.0);
    double percent90 = StatUtils.percentile(sd, 90.0);
    dataset.setPercent10((float) percent10);
    dataset.setPercent90((float) percent90);
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:11,代码来源:WiggleParser.java

示例9: computeQuantile

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private static float computeQuantile(float[] data, double quantile) {

        double[] dData = new double[data.length];
        for (int i = 0; i < data.length; i++) {
            dData[i] = data[i];
        }
        return (float) StatUtils.percentile(dData, quantile);
    }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:9,代码来源:ProcessingUtils.java

示例10: computeBounds

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private void computeBounds() {
    DoubleArrayList tmpList = new DoubleArrayList(data.length);
    for (float datum : data) {
        if (!Float.isNaN(datum)) tmpList.add(datum);
    }
    double[] tmp = tmpList.toArray();
    lowerValue = (float) StatUtils.percentile(tmp, 5);
    upperValue = (float) StatUtils.percentile(tmp, 95);
}
 
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:10,代码来源:InMemoryMatrix.java

示例11: initMinMax

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
/**
 * Set the "min" and "max" from 1MB resolutiond data.  Read a maximum of 10,000 points for this
 */
private void initMinMax() {

    final int oneMB = 1000000;
    final BBZoomLevelHeader zoomLevelHeader = getZoomLevelForScale(oneMB);

    int nValues = 0;
    double[] values = new double[10000];

    if (zoomLevelHeader == null) {
        List<String> chrNames = reader.getChromosomeNames();
        for (String chr : chrNames) {
            BigWigIterator iter = reader.getBigWigIterator(chr, 0, chr, Integer.MAX_VALUE, false);
            while (iter.hasNext()) {
                WigItem item = iter.next();
                values[nValues++] = item.getWigValue();
                if (nValues >= 10000) break;
            }
        }
    } else {

        int z = zoomLevelHeader.getZoomLevel();
        ZoomLevelIterator zlIter = reader.getZoomLevelIterator(z);
        if (zlIter.hasNext()) {
            while (zlIter.hasNext()) {
                ZoomDataRecord rec = zlIter.next();
                values[nValues++] = (rec.getMeanVal());
                if (nValues >= 10000) {
                    break;
                }
            }
        }
    }

    if (nValues > 0) {
        dataMin = StatUtils.percentile(values, 0, nValues, 10);
        dataMax = StatUtils.percentile(values, 0, nValues, 90);
    } else {
        dataMin = 0;
        dataMax = 100;
    }
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:45,代码来源:BigWigDataSource.java

示例12: computePercentile

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private int computePercentile(double percentile) {
    return (int) StatUtils.percentile(insertSizes.toArray(), 0, insertSizes.size(), percentile);
}
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:4,代码来源:PEStats.java

示例13: DataRow

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
DataRow(String[] tokens, String line) {

            double[] nonNullData = new double[nPts];
            data = new double[nPts];
            scaledData = new double[nPts];
            Arrays.fill(data, Double.NaN);
            Arrays.fill(scaledData, Double.NaN);

            calls = new String[nPts];
            Arrays.fill(calls, "");

            probe = tokens[probeColumn];
            if (descriptionColumn >= 0) {
                description = tokens[descriptionColumn];
            }

            int skip = type == FileType.RES ? 2 : 1;
            int nNonNull = 0;
            for (int dataIdx = 0; dataIdx < nPts; dataIdx++) {
                int i = dataStartColumn + dataIdx * skip;

                if (tokens[i] != null) {
                    try {
                        data[dataIdx] = Double.parseDouble(tokens[i]);

                        if (data[dataIdx] < 0) {
                            throw new RuntimeException("Negative value detected in input file: " + line);
                        }

                        double v = Math.log(data[dataIdx]) / Globals.log2;
                        scaledData[dataIdx] = v;
                        nonNullData[nNonNull] = v;
                        nNonNull++;
                    } catch (NumberFormatException e) {
                    }
                }
                if (type == FileType.RES) {
                    calls[dataIdx] = tokens[i + 1].trim();
                }
            }

            // Compute median of log values
            median = StatUtils.percentile(nonNullData, 0, nNonNull, 50);

            // Center data on median
            nNonNull = 0;
            for (int i = 0; i < scaledData.length; i++) {
                if (!Double.isNaN(scaledData[i])) {
                    scaledData[i] -= median;
                    nonNullData[nNonNull] = scaledData[i];
                    nNonNull++;
                }
            }

            // Compute modified MAD (mad based on median)
            // TODO -- shouldn't this be zero?

            //double mean = StatUtils.mean(nonNullData, 0, nNonNull);
            // The median is zero (by definition now)
            double[] deviations = new double[nNonNull];
            for (int i = 0; i < nNonNull; i++) {
                deviations[i] = Math.abs(nonNullData[i] - 0);
            }

            // MAD, as defined at http://stat.ethz.ch/R-manual/R-devel/library/stats/html/mad.html
            mad = 1.4826 * StatUtils.percentile(deviations, 50);

            // Scale data by MAD
            for (int i = 0; i < scaledData.length; i++) {
                if (!Double.isNaN(scaledData[i])) {
                    scaledData[i] /= mad;
                }
            }
        }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:75,代码来源:ExpressionFormatter.java

示例14: computeStats

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
private void computeStats(DownsampledDoubleArrayList sampledData) {

            double[] data = sampledData.toArray();
            this.percent5 = StatUtils.percentile(data, 5);
            this.percent95 = StatUtils.percentile(data, 95);

        }
 
开发者ID:theaidenlab,项目名称:Juicebox,代码行数:8,代码来源:Preprocessor.java

示例15: compute

import org.apache.commons.math.stat.StatUtils; //导入方法依赖的package包/类
public static PairedEndStats compute(Iterator<Alignment> alignments, double minPercentile, double maxPercentile) {


        double[] insertSizes = new double[MAX_PAIRS];
        int nPairs = 0;

        while (alignments.hasNext()) {


            Alignment al = alignments.next();

            if (isProperPair(al)) {
                insertSizes[nPairs] = Math.abs(al.getInferredInsertSize());
                nPairs++;
            }


            if (nPairs >= MAX_PAIRS) {
                break;
            }

        }

        if(nPairs == 0) {
            log.error("Error computing insert size distribution. No alignments in sample interval.");
            return null;
        }

        double mean = StatUtils.mean(insertSizes, 0, nPairs);
        double median = StatUtils.percentile(insertSizes, 0, nPairs, 50);
        double stdDev = Math.sqrt(StatUtils.variance(insertSizes, 0, nPairs));

        double[] deviations = new double[nPairs];
        for (int i = 0; i < nPairs; i++) {
            deviations[i] = Math.abs(insertSizes[i] - median);
        }

        // MAD, as defined at http://stat.ethz.ch/R-manual/R-devel/library/stats/html/mad.html
        double mad = 1.4826 * StatUtils.percentile(deviations, 50);

        double sec = StatUtils.percentile(insertSizes, 0, nPairs, minPercentile);
        double max = StatUtils.percentile(insertSizes, 0, nPairs, maxPercentile);

        PairedEndStats stats = new PairedEndStats(mean, median, stdDev, mad, sec, max);

        return stats;
    }
 
开发者ID:hyounesy,项目名称:ALEA,代码行数:48,代码来源:PairedEndStats.java


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