@Test public void testGetPeakValue() { Histogram h = new Histogram(0, 16, 2); h.add(1); h.add(1); h.add(1); h.add(2.5); h.add(3.5); h.add(2.1); h.add(2.1); assertEquals(3.0, h.getPeakValue(), EPSILON); }
public double getPeakValue() { int peakIndex = 0; for (int i = 1; i < frequencies.length; i++) { if (frequencies[i] > frequencies[peakIndex]) { peakIndex = i; } } int peakEndIndex = peakIndex + 1; final double EPS = 0.0001; while (peakEndIndex < frequencies.length && Math.abs(frequencies[peakEndIndex] - frequencies[peakIndex]) < EPS) { peakEndIndex++; } return ((double) peakIndex + peakEndIndex) / 2 * resolution + min; }
Histogram implements Iterable<Histogram.Bin> { public double getPeakValue() { int peakIndex = 0; for (int i = 1; i < frequencies.length; i++) { if (frequencies[i] > frequencies[peakIndex]) { peakIndex = i; } } int peakEndIndex = peakIndex + 1; final double EPS = 0.0001; while (peakEndIndex < frequencies.length && Math.abs(frequencies[peakEndIndex] - frequencies[peakIndex]) < EPS) { peakEndIndex++; } return ((double) peakIndex + peakEndIndex) / 2 * resolution + min; } }
Histogram implements Iterable<Histogram.Bin> { public double getPeakValue() { int peakIndex = 0; for (int i = 1; i < frequencies.length; i++) { if (frequencies[i] > frequencies[peakIndex]) { peakIndex = i; } } int peakEndIndex = peakIndex + 1; final double EPS = 0.0001; while (peakEndIndex < frequencies.length && Math.abs(frequencies[peakEndIndex] - frequencies[peakIndex]) < EPS) { peakEndIndex++; } return ((double) peakIndex + peakEndIndex) / 2 * resolution + min; } Histogram(double minValue, double maxValue, double resolution); }
Histogram implements Iterable<Histogram.Bin> { public double getPeakValue() { int peakIndex = 0; for (int i = 1; i < frequencies.length; i++) { if (frequencies[i] > frequencies[peakIndex]) { peakIndex = i; } } int peakEndIndex = peakIndex + 1; final double EPS = 0.0001; while (peakEndIndex < frequencies.length && Math.abs(frequencies[peakEndIndex] - frequencies[peakIndex]) < EPS) { peakEndIndex++; } return ((double) peakIndex + peakEndIndex) / 2 * resolution + min; } Histogram(double minValue, double maxValue, double resolution); void smooth(double windowLength); void circularSmooth(double windowLength); void kernelSmooth(double[] kernel); void circularKernelSmooth(double[] kernel); double[] createGaussianKernel(double length, double stdDeviation); void circularGaussianSmooth(double windowLength, double stdDeviation); void gaussianSmooth(double windowLength, double stdDeviation); void add(double value); int getSize(); double getFrequency(int index); double getPeakValue(); static Histogram fromValues(Collection<Double> samples, double resolution); @Override Iterator<Bin> iterator(); }
Histogram implements Iterable<Histogram.Bin> { public double getPeakValue() { int peakIndex = 0; for (int i = 1; i < frequencies.length; i++) { if (frequencies[i] > frequencies[peakIndex]) { peakIndex = i; } } int peakEndIndex = peakIndex + 1; final double EPS = 0.0001; while (peakEndIndex < frequencies.length && Math.abs(frequencies[peakEndIndex] - frequencies[peakIndex]) < EPS) { peakEndIndex++; } return ((double) peakIndex + peakEndIndex) / 2 * resolution + min; } Histogram(double minValue, double maxValue, double resolution); void smooth(double windowLength); void circularSmooth(double windowLength); void kernelSmooth(double[] kernel); void circularKernelSmooth(double[] kernel); double[] createGaussianKernel(double length, double stdDeviation); void circularGaussianSmooth(double windowLength, double stdDeviation); void gaussianSmooth(double windowLength, double stdDeviation); void add(double value); int getSize(); double getFrequency(int index); double getPeakValue(); static Histogram fromValues(Collection<Double> samples, double resolution); @Override Iterator<Bin> iterator();  }