From d3438e8a805693111abf06d46cc72b695d9bb835 Mon Sep 17 00:00:00 2001 From: Maxton Huff Date: Wed, 24 Mar 2021 10:58:47 -0500 Subject: [PATCH] correct k calculation and change test nth values --- executor.go | 2 +- executor_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/executor.go b/executor.go index a97d74871..0302c0c9b 100644 --- a/executor.go +++ b/executor.go @@ -1365,7 +1365,7 @@ func (e *executor) executePercentile(ctx context.Context, qcx *Qcx, index string rangeCall = intersectCall.Children[0] } - k := (1 - nth) / nth + k := (100 - nth) / nth min, max := minVal.Val, maxVal.Val // estimate nth val, eg median when nth=0.5 diff --git a/executor_test.go b/executor_test.go index 2f07b82f9..40e606c35 100644 --- a/executor_test.go +++ b/executor_test.go @@ -7127,7 +7127,7 @@ func variousQueriesOnPercentiles(t *testing.T, c *test.Cluster) { } // generate test cases per each nth argument - nths := []float64{0.0, 10, 25, 50, 75, 90, 99.99} + nths := []float64{0.0, 10, 25, 50, 75, 90, 99} var tests []testCase for _, nth := range nths { query := fmt.Sprintf(`Percentile(field="net_worth", filter=Row(val="foo"), nth=%f)`, nth)