Click here to Skip to main content
14,027,433 members
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 21 Jun 2011
Licenced CPOL

Statistical Outliers Detection: Worksheet Solution

, 23 Mar 2019
Rate this:
Please Sign up or sign in to vote.
Statistical Outliers detection in Microsoft Excel worksheet using Median() and array formula

Theoretical Background

"Outliers" are defined as numeric values in any random data set, which have an unusually high deviation from either the statistical mean (average) or the median value. In other words, these numbers are either relatively very small or too big. Detecting the outliers in a data set represents a complex statistical problem, with a corresponding variety of different methodologies and computational techniques as described, for example, in the NIST publication [1]. In general, finding the "Outliers" in a data set could be done by calculating the deviation for each number, expressed as either a "Z-score" or "modified Z-score" and testing it against certain predefined threshold. Z-score typically refers to number of standard deviation relative to the statistical average (in other words, it's measured in "Sigmas"). Modified Z-score applies the median computation technique to measure the deviation and in many cases provides more robust statistical detection of outliers. Mathematically, the Modified Z-score could be written (as suggested by Iglewicz and Hoaglin [1]) as:

Mi=0.6745 * (Xi -Median(Xi)) / MAD,

where MAD stands for Median Absolute Deviation. Any number in a data set with the absolute value of modified Z-score exceeding 3.5 is considered an "Outlier". Modified Z-score could be used to detect outliers in Microsoft Excel worksheet as described below.

Sample Computation of Outliers in Excel Worksheet Using Media/MAD

Step 1. Open Microsoft Excel worksheet and enter a sample set of 10 randomly selected numbers in column A, starting with the first row: 3, 1, -23, 7, 0, 12, -2, 7, 2, 1 (Note: don’t enter commas)

Step 2. In the first row of column C (in other words, C1), enter the formula:


The value in this cell corresponds to the median calculated on a data set entered at step 1.

Step 3. In the second row of column C (in other words, C2), enter the array formula:


The value in this cell (C2) corresponds to MAD [1].

Step 4. Enter the formula:

=IF(0.6745*(ABS(C$1-A1)>3.5*C$2), "OUTLIER", "NORMAL")

in the first row of column B and extend it down to the 10th row. Final result of “outlier’s detection” should appear in column B, indicating two "outliers" numbers (-23 and 12) as shown below:


Sample Computation of Outliers Using STD/MEAN Values

The first method described above in based on Modified Z-score and underlying Median/MAD computation. In many cases (particularly for small sample sizes), it provides more robust statistical outliers detection than a "traditional" z-score, which implies the detection based on Standard Deviation and Mean (average). Just for reference purposes, the sample computation below describes the outliers detection based on "2-Sigma" z-score; in other words, any numeric value in a data set considered an "outlier" if it's absolute value of deviation from the statistical average exceeds 2*STD. Note: As mentioned above, the first method is typically more robust and recommended for small sample sizes:

Step 1. Use the same Excel Worksheet with sample set of 10 sample numbers in column A as described in the previous example.

Step 2. Enter the formula: =AVERAGE(A1:A10) into the cell F1. This corresponds to the statistical mean calculated on a data set in column A.

Step 3. Enter the formula: =STDEV(A1:A10) into the cell F2. This corresponds to the Standard Deviation.

Step 4. Enter the formula: =IF(ABS(A1-F$1)>2*F$2,"OUTLIER", "NORMAL") in the first row of column E and extend it down to the 10th row. Final result of the “outlier’s detection” using statistical STD/AVERAGE on z-score level of 2 should appear in column E, indicating only one "outlier" number: -23 (see below); this method is missing a second outliers, which is 12, as found in the previous method.



Both methods of statistical detection of Outliers discussed above could be easily implemented within .NET Framework. Suggested MS Excel implementation based upon worksheet functions was chosen mostly to serve the didactic/demo purposes, providing the maximum level of simplicity and clarity. For more details on statistical outliers detection methodology and computation technique, you could refer to the reference [1].


  1. Detection of Outliers


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Founder Infosoft International Inc
United States United States
Dr. Alexander Bell is a seasoned full-stack Software Engineer (Win/Web/Mobile). He holds PhD in EE/IT, authored 37 inventions and published 300+ technical articles. Currently focused on Java/Javascript, .NET/C#, Android/Mobile, SQL, 'Big Data', Machine Learning, AI, IoT. Alex participated in App Innovation Contests (AIC 2102/2013) with multiple winning submissions. Portfolio samples:

  1. Educational Web Portal
  2. NY Payroll Tax Calculator (#1 on Goog)
  3. Android Fraction Calculator "Fractal MK-12"
  4. Android Prime Factorization Calculator 18-digit)
  5. Semaphon™ semantic phone num-to-text converter
  6. Real-time NY Bus Tracking Web App (IoT)
  7. WebTV powered by YouTube .NET API (#1 on Goog)
  8. Engineering Calculator VOLTA
  9. Big Data: Facebook and YouTube
  10. NY City Trivia Quiz
  11. Publications by A. Bell

You may also be interested in...


Comments and Discussions

QuestionSmall error Pin
walobu18-Feb-15 14:37
memberwalobu18-Feb-15 14:37 
GeneralRe: Thanks a bunch, ASP-DOT-NET-DEV-U-THE-BEST! :) Actually, I t... Pin
DrABELL30-Jun-11 13:37
professionalDrABELL30-Jun-11 13:37 
GeneralReason for my vote of 5 A robust, simple and efficient metho... Pin
PivotTableCell28-Jun-11 9:22
memberPivotTableCell28-Jun-11 9:22 
GeneralRe: Hi Alex, You are absolutely right: this very robust yet simp... Pin
DrABELL28-Jun-11 14:03
professionalDrABELL28-Jun-11 14:03 
GeneralHi Walt, Thanks for your note. Let's me clarify couple thing... Pin
DrABELL28-Jun-11 3:20
professionalDrABELL28-Jun-11 3:20 
GeneralIt appears that you are assuming a normal distribution, with... Pin
Walt Fair, Jr.25-Jun-11 16:22
professionalWalt Fair, Jr.25-Jun-11 16:22 
GeneralRe: FYI, Walt, DrABELL posted a comment but did not post it as a... Pin
AspDotNetDev30-Jun-11 8:58
protectorAspDotNetDev30-Jun-11 8:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190419.4 | Last Updated 23 Mar 2019
Article Copyright 2011 by DrABELL
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid