# Exponential smoothing

**URL:** <https://discourse.julialang.org/t/exponential-smoothing/41020>\
**Category:** Statistics\
**Tags:** question\
**Created:** [June 8, 2020, 10:46pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020 "2020-06-08T22:46:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [June 8, 2020, 10:46pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/1 "2020-06-08T22:46:10Z")

</div>

Is there any package in `Julia` to do exponential smoothing?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [June 8, 2020, 11:04pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/2 "2020-06-08T23:04:59Z")

</div>

I’m not aware of one, but it should be a 1-liner using `TimeSeries`

---

<div class="post-metadata">

**Author:** ![gragusa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gragusa/32/3547_2.png) [@gragusa](https://discourse.julialang.org/u/gragusa)\
**Post date:** [September 14, 2020, 7:22pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/3 "2020-09-14T19:22:32Z")

</div>

There is [https://github.com/gragusa/ExponentialSmoothing.jl](https://github.com/gragusa/ExponentialSmoothing.jl). No docs, but it should work.

---

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [September 15, 2020, 1:31pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/4 "2020-09-15T13:31:34Z")

</div>

Thank you. Can you write a small example of using your package?

---

<div class="post-metadata">

**Author:** ![joshday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshday/32/368_2.png) [@joshday](https://discourse.julialang.org/u/joshday)\
**Post date:** [September 15, 2020, 4:30pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/5 "2020-09-15T16:30:15Z")

</div>

OnlineStats does this: [Weights · OnlineStats Docs](https://joshday.github.io/OnlineStats.jl/stable/weights/#OnlineStatsBase.ExponentialWeight)

e.g.

```julia
julia> using OnlineStats

julia> x = randn(100);

julia> o = Mean(weight=ExponentialWeight(.1))
Mean: n=0 | value=0.0

julia> exp_smooth = [value(fit!(o, xi)) for xi in x]

```

---

<div class="post-metadata">

**Author:** ![ayushpatnaikgit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ayushpatnaikgit/32/25229_2.png) [@ayushpatnaikgit](https://discourse.julialang.org/u/ayushpatnaikgit)\
**Post date:** [May 19, 2021, 2:00pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/6 "2021-05-19T14:00:27Z")

</div>

> [@joshday](#):
>
> `ExponentialWeight(.1)`

Thank you, Josh. It works perfectly. Great job on the animation! Do you know if ExponentialWeight() is the same as the smoothing factor, generally denoted by alpha?

I am trying to determine the optimal value for this factor, do you know of a way to do that in Julia. In R, forecast.HoltWinters does the job.

---

<div class="post-metadata">

**Author:** ![joshday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshday/32/368_2.png) [@joshday](https://discourse.julialang.org/u/joshday)\
**Post date:** [May 19, 2021, 2:12pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/7 "2021-05-19T14:12:17Z")

</div>

Yes, for `Mean` the weight is the “smoothing factor”. Note that any `weight` is just a function of the number of observations, so you can also use

```julia
Mean(weight = n -> .1)

```

* * *

Choosing the value is pretty subjective. I’m not familiar with those methods or what metric they are trying to optimize.

---

<div class="post-metadata">

**Author:** ![guilhermebodin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guilhermebodin/32/6982_2.png) [@guilhermebodin](https://discourse.julialang.org/u/guilhermebodin)\
**Post date:** [May 23, 2021, 3:57am UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/8 "2021-05-23T03:57:54Z")

</div>

@ayushpatnaikgit[GitHub - LAMPSPUC/StateSpaceModels.jl: StateSpaceModels.jl is a Julia package for time-series analysis using state-space models.](https://github.com/LAMPSPUC/StateSpaceModels.jl) has an implementation of the state space approach for exponential smoothing. [Manual · StateSpaceModels.jl](https://lampspuc.github.io/StateSpaceModels.jl/latest/manual/#StateSpaceModels.ExponentialSmoothing)

---

<div class="post-metadata">

**Author:** ![ayushpatnaikgit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ayushpatnaikgit/32/25229_2.png) [@ayushpatnaikgit](https://discourse.julialang.org/u/ayushpatnaikgit)\
**Post date:** [June 8, 2021, 8:56am UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/9 "2021-06-08T08:56:51Z")

</div>

Hi @guilhermebodin, thank you for the excellent package. I am using it. I am also using the Kalman filter that you’ve written. I think it’ll be useful to have something similar to the tsclean function in the R Forecast by Hyndman. Is there a slack channel for the package? I could not find.

---

<div class="post-metadata">

**Author:** ![guilhermebodin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guilhermebodin/32/6982_2.png) [@guilhermebodin](https://discourse.julialang.org/u/guilhermebodin)\
**Post date:** [June 8, 2021, 2:11pm UTC](https://discourse.julialang.org/t/exponential-smoothing/41020/10 "2021-06-08T14:11:36Z")

</div>

@ayushpatnaikgit Nice to hear that you liked the package!

There is not a slack channel but we can create it. Another option is to use the statistics channel or put questions here on discourse. If you want to discuss new features you can also message me on slack
