Splunk Search

Why is the result of the median function incorrect when the total number of values is an even number?

HeinzWaescher
Motivator

Hi,

I think the median calculation is incorrect when the total amount of values is an even number.

An example:

359
282
224
150
60
52
8
1
0
0

Splunk tells me the median is 60, but it should be 56.
In this case there is a pair of middle numbers and the median should be calcualted by median=(60+52)/2

Am I correct?

BR

Heinz

Tags (1)
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

That's the documented behaviour as per http://docs.splunk.com/Documentation/Splunk/6.1.3/SearchReference/CommonStatsFunctions

median(X): This function returns the middle-most value of the field X.
           Note: The median calculation is more correct for odd numbers of events. In cases where you have
           an even number of events, the median is approximated to be the higher of the two values.

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

That's the documented behaviour as per http://docs.splunk.com/Documentation/Splunk/6.1.3/SearchReference/CommonStatsFunctions

median(X): This function returns the middle-most value of the field X.
           Note: The median calculation is more correct for odd numbers of events. In cases where you have
           an even number of events, the median is approximated to be the higher of the two values.

martin_mueller
SplunkTrust
SplunkTrust

That obviously doesn't rule out filing an Enhancement Request with Splunk Support to implement a more accurate median() function...

HeinzWaescher
Motivator

oh...thanks!

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...