# Asymmetric decile-based outlier detector, Part 1

In the previous post, I covered some problems with the outlier detector based on Tukey fences. Mainly, I discussed the probability of observing outliers using Tukey’s fences with different factors under different distributions. However, it’s not the only problem with this approach.

Since Tukey’s fences are based on quartiles, under multimodal distributions, we could get a situation when 50% of all sample elements are marked as outliers. Also, Tukey’s fences are designed for symmetric distributions, so we could get strange results with asymmetric distributions.

In this post, I want to suggest an asymmetric outlier detector based on deciles which mitigates this problem.

Let $$Q_p$$ be a quantile estimation of the $$p^\textrm{th}$$ quantile for the given sample. With this notation, Tukey’s fences introduce the following range:

$[Q_{0.25} - k (Q_{0.75} - Q_{0.25}),\, Q_{0.75} + k (Q_{0.75} - Q_{0.25})]$

All the sample elements outside this range are marked as outliers. We are going to keep the fences approach, but we will change the way of forming this range. The first improvement is simple: we replace quartiles with deciles:

$[Q_{0.1} - k (Q_{0.9} - Q_{0.1}),\, Q_{0.9} + k (Q_{0.9} - Q_{0.1})]$

With this improvement, only 20% of the sample elements could be marked as outliers (10% on each tail).

The second improvement makes this interval asymmetric:

$[Q_{0.1} - k (Q_{0.5} - Q_{0.1}),\, Q_{0.9} + k (Q_{0.9} - Q_{0.5})]$

The new interval is much more adaptive to asymmetric distributions.

In the next blog post, I will provide some examples that show the difference between the classic Tukey’s fences and the suggested asymmetric decile-based outlier detector. I will also provide some guidance about proper default value for $$k$$.
{"ft_lang_label":"__label__en","ft_lang_prob":0.89796406,"math_prob":0.99152094,"size":1809,"snap":"2022-27-2022-33","text_gpt3_token_len":474,"char_repetition_ratio":0.13185595,"word_repetition_ratio":0.021582734,"special_character_ratio":0.2835821,"punctuation_ratio":0.14713897,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99681616,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-09T05:25:04Z\",\"WARC-Record-ID\":\"<urn:uuid:3c8e1a87-a673-4481-ac39-2e416f876a8a>\",\"Content-Length\":\"10068\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:0db403c4-c5a5-4f00-937e-4a17c41a34e1>\",\"WARC-Concurrent-To\":\"<urn:uuid:5b05e133-81e2-473a-b660-f9d9bf32fabb>\",\"WARC-IP-Address\":\"185.199.109.153\",\"WARC-Target-URI\":\"https://aakinshin.net/posts/asymmetric-decile-outliers1/\",\"WARC-Payload-Digest\":\"sha1:VYAUHG6A2FQU3U7Z3TYFK3F2SM6TRYOM\",\"WARC-Block-Digest\":\"sha1:KJ34G55AL6WVZFIL6OAVXTKH67EWL4FH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882570901.18_warc_CC-MAIN-20220809033952-20220809063952-00625.warc.gz\"}"}