# \[ANN\] HampelOutliers.jl

**URL:** <https://discourse.julialang.org/t/ann-hampeloutliers-jl/111844>\
**Category:** Package Announcements\
**Tags:** outlier-detection\
**Created:** [March 19, 2024, 9:50pm UTC](https://discourse.julialang.org/t/ann-hampeloutliers-jl/111844 "2024-03-19T21:50:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)\
**Post date:** [March 19, 2024, 9:50pm UTC](https://discourse.julialang.org/t/ann-hampeloutliers-jl/111844/1 "2024-03-19T21:50:01Z")

</div>

I’ve written an [implementation](https://github.com/tobydriscoll/HampelOutliers.jl) of the Hampel filter, which is a simple yet robust way to detect and replace outliers in univariate time series without smoothing legitimate jumps. It seems to offer more flexibility than any other Julia or Python implementation I can find. But IANAS, and I make no grand claims.

For now, it’s not in the registry. Install it by direct reference, e.g.,

```julia
import Pkg; Pkg.add(url="https://github.com/tobydriscoll/HampelOutliers.jl")

```

Enjoy!

![](https://raw.githubusercontent.com/tobydriscoll/HampelOutliers.jl/main/demo_comparison.svg)

---

<div class="post-metadata">

**Author:** ![JamieC1](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@JamieC1](https://discourse.julialang.org/u/JamieC1)\
**Post date:** [March 21, 2024, 11:17am UTC](https://discourse.julialang.org/t/ann-hampeloutliers-jl/111844/2 "2024-03-21T11:17:13Z")

</div>

Can you share more about this? I want to learn how it work and on whch principle.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [March 21, 2024, 4:46pm UTC](https://discourse.julialang.org/t/ann-hampeloutliers-jl/111844/3 "2024-03-21T16:46:21Z")

</div>

I think this is the [original paper reference](https://projecteuclid.org/journals/annals-of-mathematical-statistics/volume-42/issue-6/A-General-Qualitative-Definition-of-Robustness/10.1214/aoms/1177693054.full):

_Hampel, F. R. (1971). A general qualitative definition of robustness. Annals of Mathematics Statistics, 42, 1887–1896._

---

<div class="post-metadata">

**Author:** ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)\
**Post date:** [March 21, 2024, 8:03pm UTC](https://discourse.julialang.org/t/ann-hampeloutliers-jl/111844/4 "2024-03-21T20:03:22Z")

</div>

The page [linked in the announcement](https://github.com/tobydriscoll/HampelOutliers.jl) takes you to the GitHub readme file, which gives the mathematical definition. In essence, it applies median filtering within a moving window, but it makes replacement only when the original value deviates a certain amount from the window median.

---

<div class="post-metadata">

**Author:** ![JamieC1](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@JamieC1](https://discourse.julialang.org/u/JamieC1)\
**Post date:** [March 22, 2024, 5:28am UTC](https://discourse.julialang.org/t/ann-hampeloutliers-jl/111844/5 "2024-03-22T05:28:52Z")

</div>

> [@tobydriscoll](#):
>
> The page [linked in the announcement](https://github.com/tobydriscoll/HampelOutliers.jl) takes you to the GitHub readme file, which gives the mathematical definition. In essence, it applies median filtering within a moving window, but it makes replacement only when the original value deviates a certain amount from the window median. [publixpassport](https://www.publix-passport.com/)

Thanks for your kind help!
