public void add(double datum) {
        dbuf[nd++] = datum;
        if (datum < q0) {
            q0 = datum;
        }
        if (datum > qm) {
            qm = datum;
        }
        if (nd == nbuf) {
            update();
        }
    }
@Test
    public void testAdd() {
        System.out.println("IQAgent");

        double[] data = new double[100000];
        for (int i = 0; i < data.length; i++)
            data[i] = i+1;

        MathEx.permutate(data);
        
        IQAgent instance = new IQAgent();
        for (double datum : data) instance.add(datum);

        for (int i = 1; i <= 100; i++) {
            System.out.println(i + "%\t" + instance.quantile(i/100.0) + "\t" + Math.abs(1-instance.quantile(i/100.0)/(i*1000)));
            assertTrue(Math.abs(1-instance.quantile(i/100.0)/(i*1000)) < 0.01);
        }
    }