/** * Returns the mean of the specified <code>Collection</code> of * distributions, which are assumed to be normalized arrays of * <code>double</code> values. * @see #mean(double[][]) */ public static double[] mean(Collection<double[]> distributions) { if (distributions.isEmpty()) throw new IllegalArgumentException("Distribution collection must be non-empty"); Iterator<double[]> iter = distributions.iterator(); double[] first = iter.next(); double[][] d_array = new double[distributions.size()][first.length]; d_array[0] = first; for (int i = 1; i < d_array.length; i++) d_array[i] = iter.next(); return mean(d_array); }
/** * Returns the mean of the specified <code>Collection</code> of * distributions, which are assumed to be normalized arrays of * <code>double</code> values. * @see #mean(double[][]) * @param distributions the distributions whose mean is to be calculated * @return the mean of the distributions */ public static double[] mean(Collection<double[]> distributions) { if (distributions.isEmpty()) throw new IllegalArgumentException("Distribution collection must be non-empty"); Iterator<double[]> iter = distributions.iterator(); double[] first = iter.next(); double[][] d_array = new double[distributions.size()][first.length]; d_array[0] = first; for (int i = 1; i < d_array.length; i++) d_array[i] = iter.next(); return mean(d_array); }
/** * Returns the mean of the specified <code>Collection</code> of * distributions, which are assumed to be normalized arrays of * <code>double</code> values. * * @see #mean(double[][]) */ public static double[] mean(Collection<double[]> distributions) { if (distributions.isEmpty()) { throw new IllegalArgumentException( "Distribution collection must be non-empty"); } Iterator<double[]> iter = distributions.iterator(); double[] first = iter.next(); double[][] d_array = new double[distributions.size()][first.length]; d_array[0] = first; for (int i = 1; i < d_array.length; i++) { d_array[i] = iter.next(); } return mean(d_array); }
ArrayList<double[]> locations = new ArrayList<double[]>(elements.values()); double[] mean = DiscreteDistribution.mean(locations); max_movement = Math.max(max_movement, Math.sqrt(DiscreteDistribution.squaredError(centroid, mean)));
ArrayList<double[]> locations = new ArrayList<double[]>(elements.values()); double[] mean = DiscreteDistribution.mean(locations); max_movement = Math.max(max_movement, Math.sqrt(DiscreteDistribution.squaredError(centroid, mean)));
elements.values()); double[] mean = DiscreteDistribution.mean(locations); max_movement = Math.max(max_movement, Math.sqrt( DiscreteDistribution.squaredError(centroid, mean)));