/** * Calculates the standard deviation * * @param doubles a list with values * @return the standard deviation */ public static double dev(DoubleList doubles) { if (doubles.isEmpty()) { return Double.NaN; } return Math.sqrt(variance(doubles)); }
/** * Calculates the standard deviation * * @return the standard deviation */ public double stdDeviation() { if (isEmpty()) { return Double.NaN; } return Math.sqrt(variance()); }
/** * Implemented the quantile type 7 referred to * http://tolstoy.newcastle.edu.au/R/e17/help/att-1067/Quartiles_in_R.pdf * and * http://stat.ethz.ch/R-manual/R-patched/library/stats/html/quantile.html * as its the default quantile implementation * <p> * <code> * QuantileType7 = function (v, p) { * v = sort(v) * h = ((length(v)-1)*p)+1 * v[floor(h)]+((h-floor(h))*(v[floor(h)+1]- v[floor(h)])) * } * </code> * * @param percentile - the percentile (0 - 1), e.g. 0.25 * @return the value of the n-th percentile */ public double percentile(final double percentile) { if (values.isEmpty()) { return Double.NaN; } return values.percentile(percentile); } }
/** * Implemented the quantile type 7 referred to * http://tolstoy.newcastle.edu.au/R/e17/help/att-1067/Quartiles_in_R.pdf * and * http://stat.ethz.ch/R-manual/R-patched/library/stats/html/quantile.html * as its the default quantile implementation * <p> * <code> * QuantileType7 = function (v, p) { * v = sort(v) * h = ((length(v)-1)*p)+1 * v[floor(h)]+((h-floor(h))*(v[floor(h)+1]- v[floor(h)])) * } * </code> * * @param percentile - the percentile (0 - 1), e.g. 0.25 * @return the value of the n-th percentile */ public double percentile(final double percentile) { if (values.isEmpty()) { return Double.NaN; } return values.percentile(percentile); }
/** * @param list the list * @param start the start index * @param end the end index * @return sublist */ public static DoubleList subList(DoubleList list, int start, int end) { if (list.isEmpty()) { return list; } if (start < 0 || end > list.size()) { throw new IndexOutOfBoundsException(""); } return new DoubleList(copyOfRange(list.toArray(), start, end), end - start); } }