Java Code Examples for org.apache.commons.math.stat.StatUtils#percentile()

The following examples show how to use org.apache.commons.math.stat.StatUtils#percentile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RealMatrixWrapper.java    From JuiceboxLegacy with MIT License 8 votes vote down vote up
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);

    }
 
Example 2
Source File: SymmetricMatrix.java    From JuiceboxLegacy with MIT License 7 votes vote down vote up
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);
    }
 
Example 3
Source File: HiCCoverageDataSource.java    From JuiceboxLegacy with MIT License 6 votes vote down vote up
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));
        }

    }
}
 
Example 4
Source File: HeatmapRenderer.java    From JuiceboxLegacy with MIT License 6 votes vote down vote up
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);
    }
 
Example 5
Source File: RealMatrixWrapper.java    From Juicebox with MIT License 6 votes vote down vote up
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);

    }
 
Example 6
Source File: SymmetricMatrix.java    From Juicebox with MIT License 6 votes vote down vote up
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);
    }
 
Example 7
Source File: HiCCoverageDataSource.java    From Juicebox with MIT License 6 votes vote down vote up
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));
        }

    }
}
 
Example 8
Source File: InMemoryMatrix.java    From JuiceboxLegacy with MIT License 5 votes vote down vote up
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);
}
 
Example 9
Source File: InMemoryMatrix.java    From Juicebox with MIT License 5 votes vote down vote up
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);
}
 
Example 10
Source File: HeatmapRenderer.java    From Juicebox with MIT License 5 votes vote down vote up
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);
}
 
Example 11
Source File: HeatmapRenderer.java    From Juicebox with MIT License 5 votes vote down vote up
private float computePercentile(BasicMatrix bm, double p) {
    DoubleArrayList dal = new DoubleArrayList(10000);

    for (int i = 0; i < bm.getRowDimension(); i++) {
        for (int j = i + 1; j < bm.getColumnDimension(); j++) {
            dal.add(bm.getEntry(i, j));
        }
    }

    return dal.size() == 0 ? 1 : (float) StatUtils.percentile(dal.toArray(), p);
}
 
Example 12
Source File: Preprocessor.java    From JuiceboxLegacy with MIT License 3 votes vote down vote up
private void computeStats(DownsampledDoubleArrayList sampledData) {

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

        }
 
Example 13
Source File: MatrixZoomDataPP.java    From Juicebox with MIT License 3 votes vote down vote up
private void computeStats(DownsampledDoubleArrayList sampledData) {

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

    }