以所有样本的绝对值的平方和来计算样本中的功效。
//package com.nowjava; //来自 N o w J a v a . c o m public class Main { /** * Calculates the power in a sample as sum of the squares of the absolute values of all samples. * @param sample * @return */ public static double getPower(double[] sample) { double power = 0; for (int i = 0; i < sample.length; i++) { power += Math.pow(Math.abs(sample[i]), 2); } return power; } }