Computes the mean of the given data set. @param the vector type @param dataSet the list of vectors to compute the mean of @return the mean of the vectors
(List<V> dataSet)
| 25 | * @return the mean of the vectors |
| 26 | */ |
| 27 | public static <V extends Vec> Vec meanVector(List<V> dataSet) |
| 28 | { |
| 29 | if(dataSet.isEmpty()) |
| 30 | throw new ArithmeticException("Can not compute the mean of zero data points"); |
| 31 | |
| 32 | Vec mean = new DenseVector(dataSet.get(0).length()); |
| 33 | meanVector(mean, dataSet); |
| 34 | return mean; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Computes the weighted mean of the given data set. |