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


Java VectorialCovariance.getResult方法代码示例

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


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

示例1: testMeanAndCovariance

import org.apache.commons.math3.stat.descriptive.moment.VectorialCovariance; //导入方法依赖的package包/类
@Test
public void testMeanAndCovariance() {

    VectorialMean meanStat = new VectorialMean(mean.length);
    VectorialCovariance covStat = new VectorialCovariance(mean.length, true);
    for (int i = 0; i < 5000; ++i) {
        double[] v = generator.nextVector();
        meanStat.increment(v);
        covStat.increment(v);
    }

    double[] estimatedMean = meanStat.getResult();
    RealMatrix estimatedCovariance = covStat.getResult();
    for (int i = 0; i < estimatedMean.length; ++i) {
        Assert.assertEquals(mean[i], estimatedMean[i], 0.07);
        for (int j = 0; j <= i; ++j) {
            Assert.assertEquals(covariance.getEntry(i, j),
                                estimatedCovariance.getEntry(i, j),
                                0.1 * (1.0 + FastMath.abs(mean[i])) * (1.0 + FastMath.abs(mean[j])));
        }
    }

}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:CorrelatedRandomVectorGeneratorTest.java

示例2: testMeanAndCorrelation

import org.apache.commons.math3.stat.descriptive.moment.VectorialCovariance; //导入方法依赖的package包/类
@Test
public void testMeanAndCorrelation() {

    VectorialMean meanStat = new VectorialMean(mean.length);
    VectorialCovariance covStat = new VectorialCovariance(mean.length, true);
    for (int i = 0; i < 10000; ++i) {
        double[] v = generator.nextVector();
        meanStat.increment(v);
        covStat.increment(v);
    }

    double[] estimatedMean = meanStat.getResult();
    double scale;
    RealMatrix estimatedCorrelation = covStat.getResult();
    for (int i = 0; i < estimatedMean.length; ++i) {
        Assert.assertEquals(mean[i], estimatedMean[i], 0.07);
        for (int j = 0; j < i; ++j) {
            scale = standardDeviation[i] * standardDeviation[j];
            Assert.assertEquals(0, estimatedCorrelation.getEntry(i, j) / scale, 0.03);
        }
        scale = standardDeviation[i] * standardDeviation[i];
        Assert.assertEquals(1, estimatedCorrelation.getEntry(i, i) / scale, 0.025);
    }
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:25,代码来源:UncorrelatedRandomVectorGeneratorTest.java

示例3: fit

import org.apache.commons.math3.stat.descriptive.moment.VectorialCovariance; //导入方法依赖的package包/类
public Gaussian fit(List<double[]> data) {
    k = data.get(0).length;
    int n = data.size();
    VectorialCovariance covCounter = new VectorialCovariance(k, true);
    double[] sumCounter = new double[k];

    for(double[] curDatum : data) {
        for (int i = 0; i < k; i++) {
            sumCounter[i] += curDatum[i];
        }
        covCounter.increment(curDatum);
    }
    for (int i = 0; i < k; i++) {
        sumCounter[i] /= n;
    }
    mean = sumCounter;
    cov = covCounter.getResult();
    initialize();
    return this;
}
 
开发者ID:stanford-futuredata,项目名称:macrobase,代码行数:21,代码来源:Gaussian.java


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