@Override public double p(double x) { int start = Arrays.binarySearch(this.x, x-5*h); if (start < 0) { start = -start - 1; } int end = Arrays.binarySearch(this.x, x+5*h); if (end < 0) { end = -end - 1; } double p = 0.0; for (int i = start; i < end; i++) { p += gaussian.p(this.x[i] - x); } return p / this.x.length; }