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


Java StatUtils类代码示例

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


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

示例1: rowSums

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
public static double[] rowSums(final RealMatrix m) {
    double[] result = new double[m.getRowDimension()];
    for (int i = 0; i < m.getRowDimension(); i++) {
        result[i] = StatUtils.sum(m.getRow(i));
    }
    return result;
}
 
开发者ID:cmccoy,项目名称:startreerenaissance,代码行数:8,代码来源:MatrixUtils.java

示例2: 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

示例3: getRepresentativeTrackHeight

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
/**
 * Return a representative track height to use as the default.  For now
 * using the median track height.
 *
 * @return
 */
public static int getRepresentativeTrackHeight(Collection<Track> tracks) {

    double[] heights = new double[tracks.size()];
    int i = 0;
    for (Track track : tracks) {
        heights[i] = track.getHeight();
        i++;
    }
    int medianTrackHeight = (int) Math.round(StatUtils.percentile(heights, 50));
    if (medianTrackHeight > 0) {
        return medianTrackHeight;
    }

    return PreferenceManager.getInstance().getAsInt(PreferenceManager.INITIAL_TRACK_HEIGHT);

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

示例4: getRepresentativeTrackHeight

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
/**
 * Return a representative track height to use as the default.  For now
 * using the median track height.
 *
 * @return
 */
private int getRepresentativeTrackHeight() {

    if (lastTrackHeight > 0) {
        return lastTrackHeight;
    }

    // Get all tracks except the gene track
    List<Track> tracks = IGV.getInstance().getAllTracks();


    double[] heights = new double[tracks.size()];
    for (int i = 0; i < tracks.size(); i++) {
        heights[i] = tracks.get(i).getHeight();
    }
    int medianTrackHeight = (int) Math.round(StatUtils.percentile(heights, 50));
    if (medianTrackHeight > 0) {
        return medianTrackHeight;
    }

    return PreferenceManager.getInstance().getAsInt(PreferenceManager.INITIAL_TRACK_HEIGHT);

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

示例5: 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

示例6: testMinMax

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
public void testMinMax() {
    da.addElement(2.0);
    da.addElement(22.0);
    da.addElement(-2.0);
    da.addElement(21.0);
    da.addElement(22.0);
    da.addElement(42.0);
    da.addElement(62.0);
    da.addElement(22.0);
    da.addElement(122.0);
    da.addElement(1212.0);

    assertEquals("Min should be -2.0", -2.0, StatUtils.min(da.getElements()), Double.MIN_VALUE);
    assertEquals(
        "Max should be 1212.0",
        1212.0,
        StatUtils.max(da.getElements()),
        Double.MIN_VALUE);
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:DoubleArrayAbstractTest.java

示例7: getCodonCoverage

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
private static double[] getCodonCoverage(final Alignment alignment) {
    Preconditions.checkNotNull(alignment);
    Preconditions.checkArgument(alignment.getSequenceCount() == 2,
            "Expected 2 sequences, got %s", alignment.getSequenceCount());

    final double[] result = new double[alignment.getPatternCount() / 3];
    final String qry = alignment.getAlignedSequenceString(1);

    for (int i = 0; i < result.length; i++) {
        result[i] = 0.0;
        for (int j = 0; j < 3; j++) {
            final char c = qry.charAt(3 * i + j);
            if (c != 'N' && c != '-') {
                result[i] = 1;
                continue;
            }
        }
    }

    Preconditions.checkState(StatUtils.max(result) == 1.0,
            "Unexpected maximum value: %f", StatUtils.max(result));
    return result;
}
 
开发者ID:cmccoy,项目名称:startreerenaissance,代码行数:24,代码来源:StarTreeRenaissance.java

示例8: testSerialization

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
/** test stats */
public void testSerialization() {
    
    double[] values = {35d, 23d, 42d};
    
    DescriptiveStatistics u = new BeanListUnivariateImpl( patientList, "age" ); 
    assertEquals("total count",3,u.getN(),tolerance);
    assertEquals("mean", StatUtils.mean(values), u.getMean(), tolerance);
    assertEquals("min", StatUtils.min(values), u.getMin(), tolerance);
    assertEquals("max", StatUtils.max(values), u.getMax(), tolerance);
    assertEquals("var", StatUtils.variance(values), u.getVariance(), tolerance);   
    
    
    DescriptiveStatistics u2 = (DescriptiveStatistics)TestUtils.serializeAndRecover(u); 
    assertEquals("total count",3,u2.getN(),tolerance);
    assertEquals("mean", StatUtils.mean(values), u2.getMean(), tolerance);
    assertEquals("min", StatUtils.min(values), u2.getMin(), tolerance);
    assertEquals("max", StatUtils.max(values), u2.getMax(), tolerance);
    assertEquals("var", StatUtils.variance(values), u2.getVariance(), tolerance);   

    u.clear();
    assertEquals("total count",0,u.getN(),tolerance);    
    
    u2.clear();
    assertEquals("total count",0,u2.getN(),tolerance);
        
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:28,代码来源:BeanListUnivariateImplTest.java

示例9: 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

示例10: testSample

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
@Test
public void testSample() {
    final double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    final int length = values.length;
    final double mean = StatUtils.mean(values); // 6.333...
    final SemiVariance sv = new SemiVariance();  // Default bias correction is true
    final double downsideSemiVariance = sv.evaluate(values); // Downside is the default
    Assert.assertEquals(TestUtils.sumSquareDev(new double[] {-2d, 2d, 4d, -2d, 3d, 5d}, mean) / (length - 1),
            downsideSemiVariance, 1E-14);

    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upsideSemiVariance = sv.evaluate(values);
    Assert.assertEquals(TestUtils.sumSquareDev(new double[] {22d, 11d, 14d}, mean) / (length - 1),
            upsideSemiVariance, 1E-14);

    // Verify that upper + lower semivariance against the mean sum to variance
    Assert.assertEquals(StatUtils.variance(values), downsideSemiVariance + upsideSemiVariance, 10e-12);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:19,代码来源:SemiVarianceTest.java

示例11: testMinMax

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
@Test
public void testMinMax() {
    da.addElement(2.0);
    da.addElement(22.0);
    da.addElement(-2.0);
    da.addElement(21.0);
    da.addElement(22.0);
    da.addElement(42.0);
    da.addElement(62.0);
    da.addElement(22.0);
    da.addElement(122.0);
    da.addElement(1212.0);

    Assert.assertEquals("Min should be -2.0", -2.0, StatUtils.min(da.getElements()), Double.MIN_VALUE);
    Assert.assertEquals(
        "Max should be 1212.0",
        1212.0,
        StatUtils.max(da.getElements()),
        Double.MIN_VALUE);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:DoubleArrayAbstractTest.java

示例12: testSample

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
public void testSample() {
    final double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    final int length = values.length;
    final double mean = StatUtils.mean(values); // 6.333...
    final SemiVariance sv = new SemiVariance();  // Default bias correction is true
    final double downsideSemiVariance = sv.evaluate(values); // Downside is the default
    assertEquals(TestUtils.sumSquareDev(new double[] {-2d, 2d, 4d, -2d, 3d, 5d}, mean) / (length - 1),
            downsideSemiVariance, 1E-14);

    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upsideSemiVariance = sv.evaluate(values);
    assertEquals(TestUtils.sumSquareDev(new double[] {22d, 11d, 14d}, mean) / (length - 1),
            upsideSemiVariance, 1E-14);

    // Verify that upper + lower semivariance against the mean sum to variance
    assertEquals(StatUtils.variance(values), downsideSemiVariance + upsideSemiVariance, 10e-12);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:SemiVarianceTest.java

示例13: 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

示例14: 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

示例15: testSample

import org.apache.commons.math.stat.StatUtils; //导入依赖的package包/类
public void testSample() {
    final double[] values = { -2.0d, 2.0d, 4.0d, -2.0d, 22.0d, 11.0d, 3.0d, 14.0d, 5.0d };
    final int length = values.length;
    final double mean = StatUtils.mean(values); // 6.333...
    final SemiVariance sv = new SemiVariance();  // Default bias correction is true
    final double downsideSemiVariance = sv.evaluate(values); // Downside is the default
    assertEquals(TestUtils.sumSquareDev(new double[] {-2d, 2d, 4d, -2d, 3d, 5d}, mean) / (length - 1),
            downsideSemiVariance, 1E-14);

    sv.setVarianceDirection(SemiVariance.UPSIDE_VARIANCE);
    final double upsideSemiVariance = sv.evaluate(values);
    assertEquals(TestUtils.sumSquareDev(new double[] {22d, 11d, 14d}, mean) / (length - 1),
            upsideSemiVariance, 1E-14);
    
    // Verify that upper + lower semivariance against the mean sum to variance
    assertEquals(StatUtils.variance(values), downsideSemiVariance + upsideSemiVariance, 10e-12);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:SemiVarianceTest.java


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