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