@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;
    }
@Test
    public void testP() {
        System.out.println("p");
        KernelDensity instance = new KernelDensity(x);
        double expResult = 0.10122;
        double result = instance.p(3.5);
        assertEquals(expResult, result, 1E-5);
    }