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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...