# Avarage without outliers

**URL:** <https://discuss.elastic.co/t/avarage-without-outliers/42247>\
**Category:** Elasticsearch\
**Created:** [February 19, 2016, 1:52pm UTC](https://discuss.elastic.co/t/avarage-without-outliers/42247 "2016-02-19T13:52:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![liorg2](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@liorg2](https://discuss.elastic.co/u/liorg2)\
**Post date:** [February 19, 2016, 1:52pm UTC](https://discuss.elastic.co/t/avarage-without-outliers/42247/1 "2016-02-19T13:52:04Z")

</div>

Is it possible to find the avarage without outliers using elasticsearch query? Im still using elasticsearch 1.7...

Also an option to find the avarage of all the values below the 95th percentile

Thanks!

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 19, 2016, 4:00pm UTC](https://discuss.elastic.co/t/avarage-without-outliers/42247/2 "2016-02-19T16:00:09Z")

</div>

This is not possible . I guess you could get an approximation of this number by running a histogram aggregation on your field and then computing the weighted average of the bucket keys excluding keys that are above the 95th percentile on client side.

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 19, 2016, 4:01pm UTC](https://discuss.elastic.co/t/avarage-without-outliers/42247/3 "2016-02-19T16:01:16Z")

</div>

Or you could do it in two search requests: a first one that computes the 95th percentile and a second one that adds a filter so that values are below this 95th percentile and runs an average aggregation.

---

<div class="post-metadata">

**Author:** ![liorg2](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@liorg2](https://discuss.elastic.co/u/liorg2)\
**Post date:** [February 19, 2016, 4:19pm UTC](https://discuss.elastic.co/t/avarage-without-outliers/42247/4 "2016-02-19T16:19:26Z")

</div>

I saw this great article, but it uses version 2 features

> **[Implementing a Statistical Anomaly Detector in Elasticsearch - Part 1
	  	 |...](https://www.elastic.co/blog/implementing-a-statistical-anomaly-detector-part-1)**
>
> This graph shows the min/max/avg of 45 million data points (75,000 individual time series over 600 hours). There are eight large-scale, simulated disruptions in this graph...can you spot them? No? It’...

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:14pm UTC](https://discuss.elastic.co/t/avarage-without-outliers/42247/5 "2017-07-05T23:14:48Z")

</div>


