tdigest icon indicating copy to clipboard operation
tdigest copied to clipboard

Possible bug in quantiles?

Open goller opened this issue 6 years ago • 11 comments

Hey there, I'm using

	td := tdigest.NewWithCompression(1000)
	for _, x := range []float64{1, 2, 3, 4, 5, 5, 4, 3, 2, 1} {
		td.Add(x, 1)
	}
	fmt.Println("Quantile Result")
	for _, q := range []float64{0.1, 0.2, 0.5, 0.75, 0.9, 0.99, 0.999} {
		fmt.Println(q, td.Quantile(q))
	}

The results are:

Quantile Result
0.1  1
0.2  1.5
0.5  3.071428571428571
0.75 4.142857142857142
0.9  4.785714285714285
0.99 5.171428571428571
0.999 5.209999999999999

However, I think the results should be:

0.1  1
0.2  1.5
0.5  3
0.75 4
0.9  5
0.99 5
0.999 5

goller avatar Feb 07 '18 20:02 goller