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


Java Mean.evaluate方法代码示例

本文整理汇总了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;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:Covariance.java

示例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;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:Covariance.java

示例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;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:Covariance.java

示例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;
}
 
开发者ID:arrahtech,项目名称:osdq-core,代码行数:17,代码来源:MathCalculator.java


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