This question was asked by my friend who is not internet savvy. I've no statistics background and I've been searching around internet for this question.

The question is : is it possible to replace outliers with mean value? if it's possible, is there any book reference/journals to backup this statement?

  • 28
    $\begingroup$ It is certainly possible to do this, but it is hard to imagine a situation where it makes sense to do so. $\endgroup$
    – Peter Flom
    Nov 29, 2013 at 14:22
  • 2
    $\begingroup$ Already several longer answers, but @Peter Flom's one sentence summary is unlikely to be matched as a summary. $\endgroup$
    – Nick Cox
    Nov 29, 2013 at 14:33
  • 4
    $\begingroup$ No answer has yet pointed out the elephant in the room: although replacing "outliers" by the mean preserves the average of a dataset, it changes almost any other statistic. It even changes estimates of the standard error of the mean. Accordingly--in support of @Peter Flom's comment--the resulting dataset does not appear useful for any reliable form of inference. (Conceivably it could be used not in its own right but in intermediate steps in an iterative procedure to identify outliers, thereby explaining why such a procedure might exist in the first place.) $\endgroup$
    – whuber
    Nov 29, 2013 at 17:11
  • 1
    $\begingroup$ @whuber Clearly a key point. I'd make it into another answer, so that it is not missed by anyone reading this thread too quickly. People tempted by this device, and evidently there are some, need to realise that it is (a) not a good idea (b) a bad idea. $\endgroup$
    – Nick Cox
    Nov 29, 2013 at 17:54
  • 1
    $\begingroup$ @user2357112 The implication is that the mean to be used is the mean of the other values. The outlier value, regarded as untrustworthy, should not be included in the calculation. $\endgroup$
    – Nick Cox
    Nov 30, 2013 at 11:45

8 Answers 8


Clearly it's possible, but it's not clear that it could ever be a good idea.

Let's spell out several ways in which this is a limited or deficient solution:

  • In effect you are saying that the outlier value is completely untrustworthy, to the extent that your only possible guess is that the value should be the mean. If that's what you think, it is likely to be more honest just to omit the observation in question, as evidently you don't have enough information to make a better guess.

  • With nothing else said, you need a criterion or criteria for identifying outliers in the first place (as implied by @Frank Harrell). Otherwise this is an arbitrary and subjective procedure, even if it is defended as a matter of judgment. With some criteria, it is possible that removing outliers in this way creates yet more outliers as a side-effect. An example could be that outliers are more than so many standard deviations away from the mean. Removing an outlier changes the standard deviation, and new data points may now qualify, and so on.

  • Presumably the mean here means the mean of all the other values, a point made explicit by @David Marx. The idea is ambiguous without this stipulation.

  • Using the mean may seem a safe or conservative procedure, but changing a value to the mean will change almost every other statistic, including measures of level, scale and shape and indicators of their uncertainty, a point emphasized by @whuber.

  • The mean may not even be a feasible value: simple examples are when values are integers, but typically the mean isn't an integer.

  • Even with the idea that using a summary measure is a cautious thing to do, using the mean rather than the median or any other measure needs some justification.

  • Whenever there are other variables, modifying the value of one variable without reference to others may make a data point anomalous in other senses.

What to do with outliers is an open and very difficult question. Loosely, different solutions and strategies have varying appeal.

As a very broad-brush generalisation, there is a continuum of views on outliers in statistics and machine learning from extreme pessimists to extreme optimists. Extreme pessimists feel called to serve as if officers of a Statistical Inquisition, whose duty it is to find outliers as obnoxious contaminants in the data and to deal with them severely. This could be the position, say, of people dealing with financial transactions data, most honest or genuine, but some fraudulent or criminal. Extreme optimists know that outliers are likely, and usually genuine -- the Amazon, or Amazon, is real enough, and really big. Indeed, outliers are often interesting and important and instructive. Floods, fires, and financial crises are what they are, and some are very big.

Here is a partial list of possibilities. The ordering is arbitrary and not meant to convey any order in terms of applicability, importance or any other criterion. Nor are these approaches mutually exclusive.

  • One (in my view good) definition is that "[o]utliers are sample values that cause surprise in relation to the majority of the sample" (W.N. Venables and B.D. Ripley. 2002. Modern Applied Statistics with S. New York: Springer, p.119). However, surprise is in the mind of the beholder and is dependent on some tacit or explicit model of the data. There may be another model under which the outlier is not surprising at all, so the data really are (say) lognormal or gamma rather than normal. In short, be prepared to (re)consider your model.

  • Go into the laboratory or the field and do the measurement again. Often this is not practicable, but it would seem standard in several sciences.

  • Test whether outliers are genuine. Most of the tests look pretty contrived to me, but you might find one that you can believe fits your situation. Irrational faith that a test is appropriate is always needed to apply a test that is then presented as quintessentially rational.

  • Throw them out as a matter of judgement.

  • Throw them out using some more-or-less automated (usually not "objective") rule.

  • Ignore them, partially or completely. This could be formal (e.g. trimming) or just a matter of leaving them in the dataset, but omitting them from analyses as too hot to handle.

  • Pull them in using some kind of adjustment, e.g. Winsorizing.

  • Downplay them by using some other robust estimation method.

  • Downplay them by working on a transformed scale.

  • Downplay them by using a non-identity link function.

  • Accommodate them by fitting some appropriate fat-, long-, or heavy-tailed distribution, without or with predictors.

  • Accommodate by using an indicator or dummy variable as an extra predictor in a model.

  • Side-step the issue by using some non-parametric (e.g. rank-based) procedure.

  • Get a handle on the implied uncertainty using bootstrapping, jackknifing or permutation-based procedure.

  • Edit to replace an outlier with some more likely value, based on deterministic logic. "An 18- year-old grandmother is unlikely, but the person in question was born in 1932, and it's now 2013, so presumably is really 81."

  • Edit to replace an impossible or implausible outlier using some imputation method that is currently acceptable not-quite-white magic.

  • Analyse with and without, and seeing how much difference the outlier(s) make(s), statistically, scientifically or practically.

  • Something Bayesian. My prior ignorance of quite what forbids from giving any details.

EDIT This second edition benefits from other answers and comments. I've tried to flag my sources of inspiration.

  • 2
    $\begingroup$ (+1) nice answer. On the Bayesian side, one might do many things, but in effect you're trying to build some model for how you came to have such values (the process that led to the outlier). For example, it may be something simple like "each data value has some small unknown probability of being from a distribution that's a lot wilder than the bulk of the data" and then putting a prior distribution on that probability and formalizing some choice for that wilder distribution and priors for its parameters. The effect is to down-weight the impact of points that don't fit the model. $\endgroup$
    – Glen_b
    Nov 29, 2013 at 21:55
  • 1
    $\begingroup$ In a different context, the detective Nero Wolfe advised: You have learned to accept the commonplace, you must yet learn not to exclude the bizarre. Stout, Rex. 1934. Fer-de-Lance. New York: Farrar and Rinehart. Ch.12 $\endgroup$
    – Nick Cox
    Dec 23, 2022 at 17:03

There are several problems implied by your question.

  1. What is an "outlier"?
  2. Should an "outlier" be replaced?
  3. What is special about the mean as opposed to some other estimate?
  4. How would you compensate to increase the apparent variance upon replacement by a single value that causes the variance too small?
  5. Why not use robust estimators that are resistant to outliers?
  6. Is this an independent or a dependent variable?

None of 1-5 have an obvious answer. If you really feel that these "outliers" are wrong and you don't want to use a robust statistical method, you can make them missing and use multiple imputation as one possible solution. If the variable is a dependent variable, one robust choice is ordinal regression.

  • 1
    $\begingroup$ +1, good points. I'm intrigued by the OLR suggestion; is there a reason you prefer that to using a robust loss function such as Tukey's bisquare? $\endgroup$ Dec 19, 2013 at 17:54
  • 2
    $\begingroup$ Ordinal regression is probably a bit more robust than that, and allows for estimation of well-defined quantities: means, quantiles, and probabilities. In addition you have all the power of likelihood ratio, Wald, and score tests and confidence intervals. Estimates of median $Y$ and mean $Y$ in ordinal regression are not redundant, i.e., they are not trivially connected but are allowed to "float" because of fewer distributional assumptions. $\endgroup$ Dec 20, 2013 at 12:55

The proposal has numerous flaws in it. Here is perhaps the biggest.

Suppose you are gathering data, and you see these values:

$$2, 3, 1$$

The mean, so far is $6/3 = 2$.

Then comes an outlier:

$$2, 3, 1, 1000$$

So you replace it with the mean:

$$2, 3, 1, 2$$

The next number is good:

$$2, 3, 1, 2, 7$$

Now the mean is 3. Wait a minute, the mean is now 3, but we replaced 1000 with a mean of 2, just because it occurred as the fourth value. What if we change the order of the samples?

$$2, 3, 1, 7, 1000$$

Now the mean prior to the 1000 is $(2 + 3 + 1 + 7)/4 = 13/4$. So should we replace 1000 with that mean?

The problem is that the false datum we are substituting in place of 1000 is dependent on the other data. That's an epistemological problem if the samples are supposed to represent independent measurements.

Then you have the obvious problem that you not merely withholding data that doesn't fit your assumptions, but you're falsifying it. When some unwanted result occurs, you increment $n$, and substitute a fake value. This is wrong because $n$ is supposed to be the count of samples. Now $n$ represents the number of samples, plus the number of fudge values added to the data. It basically destroys the validity of all calculations involving $n$: even those which do not use the fudge values. Your $n$ is a fudge value too!

Basically, trimming away results that don't fit is one thing (and can be justified if it is done consistently according to an algorithm, rather than according to changing mood swings of the experimenter).

Outright falsifying results is objectionable on philosophical, epistemological and ethical grounds.

There may be some extenuating circumstances, which have to do with how the results are used. Like for instance, say that this substitution of outliers by the current mean is part of some embedded computer's algorithm, which enables it to implement a closed-loop control system. (It samples some system outputs, then adjusts inputs in order to achieve control.) Everything is real time, and so something must be supplied for a given time period in the place of missing data. If this fudging helps to overcome glitches, and ensures smooth operation, then all is good.

Here is another example, from digital telephony: PLC (packet loss concealment). Crap happens, and packets get lost, yet communication is real time. PLC synthesizes fake pieces of voice based on recent pitch information from correctly received packets. So if a speaker was saying the vowel "aaa" and then a packet was lost, PLC can pad the missing packet by extrapolating the "aaa" for the frame duration (say 5 or 10 milliseconds or whatever). The "aaa" is such that it resembles the speaker's voice. This is analogous to using a "mean" to substitute for values regarded as bad. It's a good thing; it's better than the sound cutting in and out, and helps intelligibility.

If the fudging of data is part of a program of lying to people to cover up failing work, that's something else.

So, we cannot think about it independently of the application: how is the statistics being used? Will substitutions lead to invalid conclusions? Are there ethical implications?

  • $\begingroup$ The telephony story is very interesting, but it seems a matter of defensible interpolation to replace missing values. The connection with outlier replacement is tenuous, as only purely local operations are needed and local changes are secondary to the "analysis" of the entire dataset. $\endgroup$
    – Nick Cox
    Nov 30, 2013 at 12:10
  • 3
    $\begingroup$ Plenty of interesting ideas here (+1). Note, though, that the replacement procedure is not necessarily sequential. One can identify all "outliers" at once and replace all of them with the mean of the remainder. This is a consistent procedure not unlike Winsorizing. $\endgroup$
    – whuber
    Nov 30, 2013 at 18:54
  • $\begingroup$ You argue against replacing outliers with a value that is dependent on the other values in the data. Doesn't this objection apply to Winsorizing, too? In your example, 1000 would get replaced with 3 in the first sample and 7 in the second (depending, of course, on the amount of data we decide to Winsorize). $\endgroup$
    – Max
    Mar 4, 2020 at 10:30

This article by Cousineau and Chartier discusses replacing outliers with the mean


They write:

Tabachnick and Fidell (2007) suggested replacing the missing data with the mean of the remaining data in the corresponding cell. However, this procedure will tend to reduce the spread of the population, make the observed distribution more leptokurtic, and possibly increase the likelihood of a type-I error. A more elaborate technique, multiple imputations, involves replacing outliers (or missing data) with possible values (Elliott & Stettler, 2007; Serfling & Dang, 2009).

There is also an R package "outliers" that has a function to replace outliers with the mean. I also saw a number of hits in my Google search that implies that SPSS also has such a function, but I am not familiar with that program. Perhaps if you follow the threads you can discover the technical basis for the practice.


  • Cousineau, D., & Chartier, S. (2010). Outliers detection and treatment: a review. International Journal of Psychological Research, 3(1), 58-67.
  • $\begingroup$ I searched your reference for all occurrences of the word "mean" and could find no place where it discusses replacing outliers with the mean. If I missed something, could you indicate more precisely where this discussion occurs? $\endgroup$
    – whuber
    Nov 29, 2013 at 17:16
  • 1
    $\begingroup$ I changed the link because I could not get it to work. On page 9 of the document the author says "Outliers that are clearly the result of a spurious activity should be removed. However, in multivariate designs, doing so may result in removing too many participants to the point that the analysis can no longer be performed. Tabachnick and Fidell (2007) suggested replacing the missing data with the mean of the remaining data in the corresponding cell." $\endgroup$
    – Thomas
    Nov 29, 2013 at 17:40
  • 2
    $\begingroup$ Thanks: I see it now. However, describing this as a "discussion"--which suggests there may be some balancing of pros and cons--may be somewhat misleading, because this passage mentions the mean-substitution procedure (a) only for multivariate applications and (b) solely to point out its defects, winding up with a suggestion to consider multiple imputation instead. (Interestingly, the paper's reference for this procedure does not even appear in its bibliography.) $\endgroup$
    – whuber
    Nov 29, 2013 at 17:45
  • 5
    $\begingroup$ Yes it is odd that the cited reference is not in the bib. It appears to be the book "Experimental Designs Using ANOVA." I was trying to respond to the original request and provide references for the practice of substituting the mean for outliers. That paper was all I could find in a quick search and I hoped it could provide leads so that the OP could find a more complete answer. $\endgroup$
    – Thomas
    Nov 29, 2013 at 18:01

The main thing to bear in mind when dealing with outliers is whether they're providing useful information. If you expect them to occur on a regular basis then stripping them out of the data will guarantee that your model will never predict them. Of course, it depends what you want the model to do but it's worth bearing in mind that you shouldn't necessarily drop them. If they contain important information you may want to consider a model that can account for them. One, simple way to do that is to take logs of the variables, which can account for power law relationships. Alternatively, you could use a model that accounts for them with a fat-tailed distribution of errors.

If you do want to cut them out then the usual ways are to either drop them or Winsorise them to remove the extreme values. I don't have a textbook to hand but the Wiki links there do refer to some if you want to read further. Most texts on applied statistics should have a section on outliers.


I'm aware of two related similar approaches in statistics.

  • Trimmed means: when computing the mean, you drop the smallest and largest observations of your data (e.g. the top and bottom $1%$ each; you should do this symmetrically!)
  • Winsorization: similar to the trimmed mean, you only modify extreme observations. However, instead of dropping them, you replace them with the largest/smallest non-extreme observation. This often works slightly better than trimming.

For more detailed examples, see Wikipedia:



Note that this works good for some statistics such as when computing the mean. The trimmed / winsorized mean is often a better estimate of the true mean than the artihmetic average. In other cases, it may ruin your statistics. For example when computing variance, trimming will always underestimate your true variance. Winsorization, assuming that indeed some of the extreme observations are faulty, will work a bit better then (it will probably still underestimate, but not by as much).

I don't see how replacing the extreme values with the mean would fit in here.

However, there is another practice that is related: missing value imputation. Assuming that your outlier is flawed, worthless data, so your remove it. When you then perform imputation, a typical substitute value would be the mean or mode:


  • 1
    $\begingroup$ Trimming asymmetrically is a known and defensible tactic. $\endgroup$
    – Nick Cox
    Nov 30, 2013 at 1:34

The traditional approach for handling outliers is to simply remove them such that your model is trained only on "good" data.

Keep in mind that the mean value is affected by the presence of those outliers. If you replace outliers with the mean calculated after the outliers were removed from your dataset, it will make no difference since the regression line (from simple linear regression) will pass through the mean of your training data anyway (this will reduce the variance of your estimates though, which is probably the opposite of what you want given that you know there are outliers).

The effect your approach will have on the model depends on the influence (leverage) of the outlier. I'd recommend against the approach you suggest in lieu of just removing the point entirely.

  • 4
    $\begingroup$ Removal of data will cause a bias unless the procedure for removal is objective and that same procedure will be applied to all future data for which predictions are obtained. $\endgroup$ Nov 29, 2013 at 14:26

yes the outliers can be replaced in may forms, for example, let's take a data-set of the size of Human heights, let's say we have some outliers like 500 cm and 400 cm then, we can just replace those data points that appear in the dataset because of some error that was caused during the recording of the data. so the options you can try is 1. replace it with the Median of the Whole color of the data (not the mean, as it is prone to outliers). 2. replace with the most Occurring data point in the Column. 3. If Categorial values then you can try Response coding.(wherein you Record the Probability of the word or the values occurring by the total number of words )


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.