/** * Gets the Median Absolute Deviation (MAD) from a array of numbers. * * @param data the array of numbers * @return the mad */ public static double mad(final double... data) { if (data.length == 0) { return 0; } final double median = median(data); final double[] deviationSum = new double[data.length]; for (int i = 0; i < data.length; i++) { deviationSum[i] = Math.abs(median - data[i]); } return median(deviationSum); }
/** * Gets the Median absolute deviation (MAD) from a array of numbers. * * @param data the array of numbers * @return the mad */ public static double mad(final double[] data) { double mad = 0; if (data.length > 0) { double median = median(data); double[] deviationSum = new double[data.length]; for (int i = 0; i < data.length; i++) { deviationSum[i] = Math.abs(median - data[i]); } mad = median(deviationSum); } return mad; }
@Override public double getUtilizationMad() { if (history.isEmpty()) { return 0; } final int maxEntries = getNumEntriesToComputeStats(); final double median = MathUtil.median(getHistory().values()); final double[] deviationSum = new double[maxEntries]; for (int i = 0; i < maxEntries; i++) { deviationSum[i] = Math.abs(median - getHistory().get(i)); } return MathUtil.median(deviationSum); }
/** * Gets the tricube bisquare weigths. * * @param residuals the residuals array * @return the tricube bisquare weigths */ public static double[] getTricubeBisquareWeights(final double... residuals) { final double[] weights = getTricubeWeights(residuals.length); final double[] weights2 = new double[residuals.length]; final double s6 = median(abs(residuals)) * 6; for (int i = 2; i < residuals.length; i++) { final double k = Math.pow(1 - Math.pow(residuals[i] / s6, 2), 2); weights2[i] = k > 0 ? (1 / k) * weights[i] : Double.MAX_VALUE; } weights2[0] = weights2[1] = weights2[2]; return weights2; }
/** * Defines a dynamic CPU utilization threshold that indicates a Vm is overloaded. * Such a threshold is the maximum CPU a VM can use before requesting vertical CPU scaling. * A reference to this method is assigned to each Vertical VM Scaling created. * * <p>The dynamic upper threshold is defined as 20% above the mean (mean * 1.2), * if there are at least 10 CPU utilization history entries. * That means if the CPU utilization of a VM is 20% above its mean * CPU utilization, it indicates the VM is overloaded. * If there aren't enough history entries, * it defines a static threshold as 70% of CPU utilization.</p> * * @param vm the VM to check if its CPU is overloaded. * The parameter is not being used internally, that means the same * threshold is used for any Vm. * @return the upper dynamic CPU utilization threshold * @see #createVerticalPeScaling() */ private double upperCpuUtilizationThreshold(Vm vm) { final List<Double> history = vm.getUtilizationHistory().getHistory().values().stream().collect(Collectors.toList()); return history.size() > 10 ? MathUtil.median(history) * 1.2 : 0.7; }
/** * Gets the tricube bisquare weigths. * * @param residuals the residuals array * @return the tricube bisquare weigths * @todo The word "weight" is misspelled in the method name. */ public static double[] getTricubeBisquareWeigts(final double[] residuals) { int n = residuals.length; double[] weights = getTricubeWeigts(n); double[] weights2 = new double[n]; double s6 = median(abs(residuals)) * 6; for (int i = 2; i < n; i++) { double k = Math.pow(1 - Math.pow(residuals[i] / s6, 2), 2); if (k > 0) { weights2[i] = (1 / k) * weights[i]; } else { weights2[i] = Double.MAX_VALUE; } } weights2[0] = weights2[1] = weights2[2]; return weights2; }
/** * Gets the utilization MAD in MIPS. * * @return the utilization mean in MIPS */ public double getUtilizationMad() { double mad = 0; if (!getUtilizationHistory().isEmpty()) { int n = HISTORY_LENGTH; if (HISTORY_LENGTH > getUtilizationHistory().size()) { n = getUtilizationHistory().size(); } double median = MathUtil.median(getUtilizationHistory()); double[] deviationSum = new double[n]; for (int i = 0; i < n; i++) { deviationSum[i] = Math.abs(median - getUtilizationHistory().get(i)); } mad = MathUtil.median(deviationSum); } return mad; }
/** * Gets the utilization MAD in MIPS. * * @return the utilization MAD in MIPS */ public double getUtilizationMad() { double mad = 0; if (!getUtilizationHistory().isEmpty()) { int n = HISTORY_LENGTH; if (HISTORY_LENGTH > getUtilizationHistory().size()) { n = getUtilizationHistory().size(); } double median = MathUtil.median(getUtilizationHistory()); double[] deviationSum = new double[n]; for (int i = 0; i < n; i++) { deviationSum[i] = Math.abs(median - getUtilizationHistory().get(i)); } mad = MathUtil.median(deviationSum); } return mad; }
/** * Gets the utilization MAD in MIPS. * * @return the utilization mean in MIPS */ public double getUtilizationMad() { double mad = 0; if (!getUtilizationHistory().isEmpty()) { int n = HISTORY_LENGTH; if (HISTORY_LENGTH > getUtilizationHistory().size()) { n = getUtilizationHistory().size(); } double median = MathUtil.median(getUtilizationHistory()); double[] deviationSum = new double[n]; for (int i = 0; i < n; i++) { deviationSum[i] = Math.abs(median - getUtilizationHistory().get(i)); } mad = MathUtil.median(deviationSum); } return mad; }
/** * Gets the utilization MAD in MIPS. * * @return the utilization mean in MIPS */ public double getUtilizationMad() { double mad = 0; if (!getUtilizationHistory().isEmpty()) { int n = HISTORY_LENGTH; if (HISTORY_LENGTH > getUtilizationHistory().size()) { n = getUtilizationHistory().size(); } double median = MathUtil.median(getUtilizationHistory()); double[] deviationSum = new double[n]; for (int i = 0; i < n; i++) { deviationSum[i] = Math.abs(median - getUtilizationHistory().get(i)); } mad = MathUtil.median(deviationSum); } return mad; }
meanTimeBeforeHostShutdown = MathUtil.mean(timeBeforeHostShutdown); stDevTimeBeforeHostShutdown = MathUtil.stDev(timeBeforeHostShutdown); medTimeBeforeHostShutdown = MathUtil.median(timeBeforeHostShutdown); meanTimeBeforeContainerMigration = MathUtil.mean(timeBeforeContainerMigration); stDevTimeBeforeContainerMigration = MathUtil.stDev(timeBeforeContainerMigration); medTimeBeforeContainerMigration = MathUtil.median(timeBeforeContainerMigration); meanActiveVm = MathUtil.mean(activeVm); stDevActiveVm = MathUtil.stDev(activeVm); medActiveVm = MathUtil.median(activeVm); meanActiveHosts = MathUtil.mean(activeHost); stDevActiveHosts = MathUtil.stDev(activeHost); medActiveHosts = MathUtil.median(activeHost); meanNumberOfContainerMigrations = MathUtil.mean(numberOfContainerMigrations); stDevNumberOfContainerMigrations = MathUtil.stDev(numberOfContainerMigrations); medNumberOfContainerMigrations = MathUtil.median(numberOfContainerMigrations); meanDatacenterEnergy = MathUtil.mean(datacenterEnergy); stDevDatacenterEnergy = MathUtil.stDev(datacenterEnergy); medDatacenterEnergy = MathUtil.median(datacenterEnergy);