Cleaning up BeanTest, nicer toString using Beans, cleaner statistics output (but not yet done)

This commit is contained in:
Marcel Kronfeld
2008-02-12 10:09:46 +00:00
parent e3f2768a29
commit 260d6e89ae
20 changed files with 432 additions and 386 deletions

View File

@@ -320,6 +320,22 @@ public class StatisticUtils
}
return sum;
}
/**
* Computes the 2-norm of an array of doubles.
*
* @param doubles the array of double
* @return the 2-norm of the elements
*/
public static double norm(double[] doubles) {
double sqSum = 0;
for (int i = 0; i < doubles.length; i++) {
sqSum += doubles[i]*doubles[i];
}
return Math.sqrt(sqSum);
}
/**
* Computes the sum of the elements of an array of integers.