本文整理汇总了Java中org.apache.commons.math.stat.descriptive.moment.Mean.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java Mean.evaluate方法的具体用法?Java Mean.evaluate怎么用?Java Mean.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.stat.descriptive.moment.Mean
的用法示例。
在下文中一共展示了Mean.evaluate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: covariance
import org.apache.commons.math.stat.descriptive.moment.Mean; //导入方法依赖的package包/类
/**
* Computes the covariance between the two arrays.
*
* <p>Array lengths must match and the common length must be at least 2.</p>
*
* @param xArray first data array
* @param yArray second data array
* @param biasCorrected if true, returned value will be bias-corrected
* @return returns the covariance for the two arrays
* @throws IllegalArgumentException if the arrays lengths do not match or
* there is insufficient data
*/
public double covariance(final double[] xArray, final double[] yArray, boolean biasCorrected)
throws IllegalArgumentException {
Mean mean = new Mean();
double result = 0d;
int length = xArray.length;
if(length == yArray.length && length > 1) {
double xMean = mean.evaluate(xArray);
double yMean = mean.evaluate(yArray);
for (int i = 0; i < length; i++) {
double xDev = xArray[i] - xMean;
double yDev = yArray[i] - yMean;
result += (xDev * yDev - result) / (i + 1);
}
}
else {
throw MathRuntimeException.createIllegalArgumentException(
"arrays must have the same length and both must have at " +
"least two elements. xArray has size {0}, yArray has {1} elements",
length, yArray.length);
}
return biasCorrected ? result * ((double) length / (double)(length - 1)) : result;
}
示例2: covariance
import org.apache.commons.math.stat.descriptive.moment.Mean; //导入方法依赖的package包/类
/**
* Computes the covariance between the two arrays.
*
* <p>Array lengths must match and the common length must be at least 2.</p>
*
* @param xArray first data array
* @param yArray second data array
* @param biasCorrected if true, returned value will be bias-corrected
* @return returns the covariance for the two arrays
* @throws IllegalArgumentException if the arrays lengths do not match or
* there is insufficient data
*/
public double covariance(final double[] xArray, final double[] yArray, boolean biasCorrected)
throws IllegalArgumentException {
Mean mean = new Mean();
double result = 0d;
int length = xArray.length;
if (length != yArray.length) {
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, length, yArray.length);
} else if (length < 2) {
throw MathRuntimeException.createIllegalArgumentException(
LocalizedFormats.INSUFFICIENT_DIMENSION, length, 2);
} else {
double xMean = mean.evaluate(xArray);
double yMean = mean.evaluate(yArray);
for (int i = 0; i < length; i++) {
double xDev = xArray[i] - xMean;
double yDev = yArray[i] - yMean;
result += (xDev * yDev - result) / (i + 1);
}
}
return biasCorrected ? result * ((double) length / (double)(length - 1)) : result;
}
示例3: covariance
import org.apache.commons.math.stat.descriptive.moment.Mean; //导入方法依赖的package包/类
/**
* Computes the covariance between the two arrays.
*
* <p>Array lengths must match and the common length must be at least 2.</p>
*
* @param xArray first data array
* @param yArray second data array
* @param biasCorrected if true, returned value will be bias-corrected
* @return returns the covariance for the two arrays
* @throws IllegalArgumentException if the arrays lengths do not match or
* there is insufficient data
*/
public double covariance(final double[] xArray, final double[] yArray, boolean biasCorrected)
throws IllegalArgumentException {
Mean mean = new Mean();
double result = 0d;
int length = xArray.length;
if(length == yArray.length && length > 1) {
double xMean = mean.evaluate(xArray);
double yMean = mean.evaluate(yArray);
for (int i = 0; i < length; i++) {
double xDev = xArray[i] - xMean;
double yDev = yArray[i] - yMean;
result += (xDev * yDev - result) / (i + 1);
}
}
else {
throw MathRuntimeException.createIllegalArgumentException(
"arrays must have the same length and both must have at " +
"least two elements. xArray has size {0}, yArray has {1} elements",
length, yArray.length);
}
return biasCorrected ? result * ((double) length / (double)(length - 1)) : result;
}
示例4: calculateMean
import org.apache.commons.math.stat.descriptive.moment.Mean; //导入方法依赖的package包/类
/**
* Calculates the mean of all attribute values.
*
* @param attributeValues attribute values
* @return the mean
*/
public Double calculateMean( Comparable[] attributeValues ) {
Mean mean = new Mean();
Double evaluatedMean
= mean.evaluate( convertToPrimitives( attributeValues ) );
log.debug( "mean = " + evaluatedMean );
return evaluatedMean;
}