Tag: code

  • Calculating the mean and standard deviation in one pass

    It is possible to calculate the mean and the standard deviation of a serie of double values while iterating only once on the whole set of data. This approach is thus also suitable for streaming data; it could update the mean and standard deviation on-the-fly. Here I present an implementation of the algorithm shown by […]

  • Getting the number of dimensions of a multidimensional array in Java

    Based on my about cloning multidimensional arrays, I have come up with a short static function to get the number of dimensions which a multidimensional array has. Note that this method only returns the number of dimensions of the original object passed as argument. It does not expand into the contained objects themselves. Example: prints […]

  • Cloning multidimensional arrays in Java

    In Java, calling the clone() method on an array returns a copy of the array, that is a new array containing references to the same objects as the source array. In particular, the objects themselves are not copied. As multidimensional arrays are just arrays of arrays, cloning a multidimensional array result in only the first […]