TrimmedMean

TrimmedMean[list,f]

gives the mean of the elements in list after dropping a fraction f of the smallest and largest elements.

TrimmedMean[list,{f1,f2}]

gives the mean when a fraction f1 of the smallest elements and a fraction f2 of the largest elements are removed.

TrimmedMean[list]

gives the 5% trimmed mean TrimmedMean[list,0.05].

TrimmedMean[dist,]

gives the trimmed mean of a univariate distribution dist.

Details

  • TrimmedMean gives a robust estimate of the mean by excluding extreme values.
  • The trimming fraction is determined by the parameters f1 and f2, which indicate the fraction f1 of the smallest elements and the fraction f2 of the largest elements to be removed.
  • TrimmedMean[list,{f1,f2}] gives the mean of Sort[list,Less]1+;;n-, where n equals the length of list.
  • TrimmedMean[{{x1,y1,},{x2,y2,},},f] gives {TrimmedMean[{x1,x2,},f],TrimmedMean[{y1,y2,},f],}.
  • TrimmedMean[dist,{f1,f2}] gives Mean[TruncatedDistribution[Quantile[dist,{f1,1-f2}],dist]] for a univariate distribution dist.

Examples

open allclose all

Basic Examples  (3)

Trimmed mean after removing extreme values:

Trimmed mean after removing the smallest extreme values:

Trimmed mean of a symbolic distribution:

Scope  (8)

Data  (7)

Exact input yields exact output:

Approximate input yields approximate output:

TrimmedMean for a matrix gives columnwise means:

Trimmed mean works with large arrays:

SparseArray data can be used just like dense arrays:

Trimmed mean of a TimeSeries:

Trimmed mean depends only on the values:

Trimmed mean works with data involving quantities:

Distributions  (1)

The trimmed mean for a univariate distribution:

Applications  (3)

Obtain a robust estimate of location when outliers are present:

Extreme values have a large influence on the Mean:

Simulate a trajectory with heavy-tailed measurement noise:

The underlying signal and simulated path with noise:

Smooth the trajectory using a moving TrimmedMean:

Increasing the block size gives a smoother trajectory:

Find a trimmed mean for the heights of children in a class:

Compare a few trimmed means:

Plot the trimmed mean as a function of trimmed fraction:

Properties & Relations  (5)

A 0% TrimmedMean is equivalent to Mean:

TrimmedMean approaches Median as f approaches 1/2:

TrimmedMean of a distribution is the mean of its TruncatedDistribution:

Mean of the TruncatedDistribution with appropriate bounds:

TrimmedMean of a sample gives an estimate of the mean of a truncated distribution:

Mean of the TruncatedDistribution with appropriate bounds:

TrimmedMean drops the data beyond a certain quantile level, then computes the sample mean:

WinsorizedMean clips the data beyond a certain quantile level, then computes the sample mean:

Plot the sorted data against the sample with elements removed and the clipped sample:

Possible Issues  (1)

TrimmedMean requires numeric values:

Wolfram Research (2007), TrimmedMean, Wolfram Language function, https://reference.wolfram.com/language/ref/TrimmedMean.html (updated 2017).

Text

Wolfram Research (2007), TrimmedMean, Wolfram Language function, https://reference.wolfram.com/language/ref/TrimmedMean.html (updated 2017).

CMS

Wolfram Language. 2007. "TrimmedMean." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/TrimmedMean.html.

APA

Wolfram Language. (2007). TrimmedMean. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TrimmedMean.html

BibTeX

@misc{reference.wolfram_2023_trimmedmean, author="Wolfram Research", title="{TrimmedMean}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/TrimmedMean.html}", note=[Accessed: 19-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_trimmedmean, organization={Wolfram Research}, title={TrimmedMean}, year={2017}, url={https://reference.wolfram.com/language/ref/TrimmedMean.html}, note=[Accessed: 19-March-2024 ]}