All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.dagere.kopeme.measuresummarizing.MedianSummarizer Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package de.dagere.kopeme.measuresummarizing;

import java.util.Arrays;
import java.util.List;

public class MedianSummarizer implements MeasureSummarizer {

	/**
	 * Returns the median of the List of measures
	 * @return median of the liste of measures
	 */
	@Override
	public long getValue(List values) {
		Long longarray[] = values.toArray(new Long[0]);
		Arrays.sort(longarray);
		int middle = ((longarray.length) / 2);
		long median;
		if (longarray.length % 2 == 0) {
			long medianA = longarray[middle];
			long medianB = longarray[middle - 1];
			median = (medianA + medianB) / 2;
		} else {
			median = longarray[middle + 1];
		}
		return median;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy