/** * Gets the Variance from a list of numbers. * * @param list the list of numbers * @return the variance */ public static double variance(final List<Double> list) { long n = 0; double mean = mean(list); double s = 0.0; for (double x : list) { n++; double delta = x - mean; mean += delta / n; s += delta * (x - mean); } // if you want to calculate std deviation // of a sample change this to (s/(n-1)) return s / (n - 1); }
/** * Gets the Variance from a list of numbers. * * @param list the list of numbers * @return the variance */ public static double variance(final List<Double> list) { long count = 0; double mean = mean(list); double deltaSum = 0.0; for(final double x : list) { count++; final double delta = x - mean; mean += delta / count; deltaSum += delta * (x - mean); } return deltaSum / (count - 1); }
metrics.put("average", 0.); } else { metrics.put("average", MathUtil.mean(slaViolation));
metrics.put("average", 0.); } else { metrics.put("average", MathUtil.mean(slaViolation));
double medTimeBeforeHostShutdown = Double.NaN; if (!timeBeforeHostShutdown.isEmpty()) { meanTimeBeforeHostShutdown = MathUtil.mean(timeBeforeHostShutdown); stDevTimeBeforeHostShutdown = MathUtil.stDev(timeBeforeHostShutdown); medTimeBeforeHostShutdown = MathUtil.median(timeBeforeHostShutdown); double medTimeBeforeContainerMigration = Double.NaN; if (!timeBeforeContainerMigration.isEmpty()) { meanTimeBeforeContainerMigration = MathUtil.mean(timeBeforeContainerMigration); stDevTimeBeforeContainerMigration = MathUtil.stDev(timeBeforeContainerMigration); medTimeBeforeContainerMigration = MathUtil.median(timeBeforeContainerMigration); double medActiveVm = Double.NaN; if (!activeVm.isEmpty()) { meanActiveVm = MathUtil.mean(activeVm); stDevActiveVm = MathUtil.stDev(activeVm); medActiveVm = MathUtil.median(activeVm); double medActiveHosts = Double.NaN; if (!activeHost.isEmpty()) { meanActiveHosts = MathUtil.mean(activeHost); stDevActiveHosts = MathUtil.stDev(activeHost); medActiveHosts = MathUtil.median(activeHost); double medNumberOfContainerMigrations = Double.NaN; if (!numberOfContainerMigrations.isEmpty()) { meanNumberOfContainerMigrations = MathUtil.mean(numberOfContainerMigrations); stDevNumberOfContainerMigrations = MathUtil.stDev(numberOfContainerMigrations); medNumberOfContainerMigrations = MathUtil.median(numberOfContainerMigrations);
double stDevTimeBeforeHostShutdown = Double.NaN; if (!timeBeforeHostShutdown.isEmpty()) { meanTimeBeforeHostShutdown = MathUtil.mean(timeBeforeHostShutdown); stDevTimeBeforeHostShutdown = MathUtil.stDev(timeBeforeHostShutdown); double stDevTimeBeforeVmMigration = Double.NaN; if (!timeBeforeVmMigration.isEmpty()) { meanTimeBeforeVmMigration = MathUtil.mean(timeBeforeVmMigration); stDevTimeBeforeVmMigration = MathUtil.stDev(timeBeforeVmMigration); double executionTimeVmSelectionMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryVmSelection()); double executionTimeVmSelectionStDev = MathUtil.stDev(vmAllocationPolicy .getExecutionTimeHistoryVmSelection()); double executionTimeHostSelectionMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryHostSelection()); double executionTimeHostSelectionStDev = MathUtil.stDev(vmAllocationPolicy .getExecutionTimeHistoryHostSelection()); double executionTimeVmReallocationMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryVmReallocation()); double executionTimeVmReallocationStDev = MathUtil.stDev(vmAllocationPolicy .getExecutionTimeHistoryVmReallocation()); double executionTimeTotalMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryTotal()); double executionTimeTotalStDev = MathUtil.stDev(vmAllocationPolicy double executionTimeVmSelectionMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryVmSelection()); double executionTimeVmSelectionStDev = MathUtil.stDev(vmAllocationPolicy
double stDevTimeBeforeHostShutdown = Double.NaN; if (!timeBeforeHostShutdown.isEmpty()) { meanTimeBeforeHostShutdown = MathUtil.mean(timeBeforeHostShutdown); stDevTimeBeforeHostShutdown = MathUtil.stDev(timeBeforeHostShutdown); double stDevTimeBeforeVmMigration = Double.NaN; if (!timeBeforeVmMigration.isEmpty()) { meanTimeBeforeVmMigration = MathUtil.mean(timeBeforeVmMigration); stDevTimeBeforeVmMigration = MathUtil.stDev(timeBeforeVmMigration); double stDevTimeBeforeContainerMigration = Double.NaN; if (!timeBeforeContainerMigration.isEmpty()) { meanTimeBeforeContainerMigration = MathUtil.mean(timeBeforeContainerMigration); stDevTimeBeforeContainerMigration = MathUtil.stDev(timeBeforeContainerMigration); double executionTimeVmSelectionMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryVmSelection()); double executionTimeVmSelectionStDev = MathUtil.stDev(vmAllocationPolicy .getExecutionTimeHistoryVmSelection()); double executionTimeHostSelectionMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryHostSelection()); double executionTimeHostSelectionStDev = MathUtil.stDev(vmAllocationPolicy .getExecutionTimeHistoryHostSelection()); double executionTimeVmReallocationMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryVmReallocation()); double executionTimeVmReallocationStDev = MathUtil.stDev(vmAllocationPolicy .getExecutionTimeHistoryVmReallocation()); double executionTimeTotalMean = MathUtil.mean(vmAllocationPolicy .getExecutionTimeHistoryTotal());