本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.moment.Variance.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java Variance.evaluate方法的具体用法?Java Variance.evaluate怎么用?Java Variance.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.stat.descriptive.moment.Variance
的用法示例。
在下文中一共展示了Variance.evaluate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: estBetaDist
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
public static double[] estBetaDist(double[] betaValues) {
Mean mean = new Mean();
double mu = mean.evaluate(betaValues,0,betaValues.length);
Variance variance = new Variance();
double var = variance.evaluate(betaValues, mu);
double alpha = -mu*(var+mu*mu-mu)/var;
double beta = (mu-1)*(var+mu*mu-mu)/var;
return new double[] {alpha, beta, mu, FastMath.sqrt(var)};
}
示例2: getExpectedValue
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
@Override
public Number getExpectedValue(int start, int length)
{
if (length == 0) {
return null;
}
double[] values = new double[length];
for (int i = 0; i < length; i++) {
values[i] = start + i;
}
Variance variance = new Variance(false);
return variance.evaluate(values);
}
示例3: getExpectedValue
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
@Override
public Number getExpectedValue(int start, int length)
{
if (length < 2) {
return null;
}
double[] values = new double[length];
for (int i = 0; i < length; i++) {
values[i] = start + i;
}
Variance variance = new Variance();
return variance.evaluate(values);
}
示例4: getVariance
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/** Compute variance of the samples.
*
* @return Variance of the data in the original benchmark run.
*/
public synchronized double getVariance() {
if (cacheVariance == null) {
Variance mean = new Variance();
cacheVariance = mean.evaluate(data);
}
return cacheVariance;
}
示例5: stop
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
protected Result stop(boolean interarrival) {
double cpu = ((double)(mxbean.getCurrentThreadCpuTime()-cputime))/idx;
if (interarrival) {
for(int i = idx-1; i>0; i--)
times[i]-=times[i-1];
begin = 1;
}
Mean mean = new Mean();
double m = mean.evaluate(times, begin, idx-begin);
Variance var = new Variance();
double v = var.evaluate(times, m, begin, idx-begin);
return new Result(m, v, cpu);
}
示例6: testConsistency
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/**
* Verify that diagonal entries are consistent with Variance computation and matrix matches
* column-by-column covariances
*/
@Test
public void testConsistency() {
final RealMatrix matrix = createRealMatrix(swissData, 47, 5);
final RealMatrix covarianceMatrix = new Covariance(matrix).getCovarianceMatrix();
// Variances on the diagonal
Variance variance = new Variance();
for (int i = 0; i < 5; i++) {
Assert.assertEquals(variance.evaluate(matrix.getColumn(i)), covarianceMatrix.getEntry(i,i), 10E-14);
}
// Symmetry, column-consistency
Assert.assertEquals(covarianceMatrix.getEntry(2, 3),
new Covariance().covariance(matrix.getColumn(2), matrix.getColumn(3), true), 10E-14);
Assert.assertEquals(covarianceMatrix.getEntry(2, 3), covarianceMatrix.getEntry(3, 2), Double.MIN_VALUE);
// All columns same -> all entries = column variance
RealMatrix repeatedColumns = new Array2DRowRealMatrix(47, 3);
for (int i = 0; i < 3; i++) {
repeatedColumns.setColumnMatrix(i, matrix.getColumnMatrix(0));
}
RealMatrix repeatedCovarianceMatrix = new Covariance(repeatedColumns).getCovarianceMatrix();
double columnVariance = variance.evaluate(matrix.getColumn(0));
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
Assert.assertEquals(columnVariance, repeatedCovarianceMatrix.getEntry(i, j), 10E-14);
}
}
// Check bias-correction defaults
double[][] data = matrix.getData();
TestUtils.assertEquals("Covariances",
covarianceMatrix, new Covariance().computeCovarianceMatrix(data),Double.MIN_VALUE);
TestUtils.assertEquals("Covariances",
covarianceMatrix, new Covariance().computeCovarianceMatrix(data, true),Double.MIN_VALUE);
double[] x = data[0];
double[] y = data[1];
Assert.assertEquals(new Covariance().covariance(x, y),
new Covariance().covariance(x, y, true), Double.MIN_VALUE);
}
示例7: variance
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/** Compute variance of given data with bias correction.
*
* @param values Array of values to compute the variance from.
* @return Varince of the provided values.
*/
public static double variance(double... values) {
Variance var = new Variance();
return var.evaluate(values);
}
示例8: varianceN
import org.apache.commons.math3.stat.descriptive.moment.Variance; //导入方法依赖的package包/类
/** Compute variance of given data without bias correction.
*
* @param values Array of values to compute the variance from.
* @return Varince of the provided values.
*/
public static double varianceN(double... values) {
Variance var = new Variance(false);
return var.evaluate(values);
}