Exponential Smoothing
#平滑化 #統計 #Animation
https://gyazo.com/467be3b064005bfe40bff0d2b8411e47
https://editor.p5js.org/0b5vr/sketches/wuZk2LMMx
値を指数的に平滑化する手法
統計でよく用いられるアプローチだが、Animation・可視化などでも応用可能
https://en.wikipedia.org/wiki/Exponential_smoothing
$ x_iを入力値・$ s_iを出力値とする
$ 0 < \alpha < 1のとき、lerpを用いて
$ \begin{aligned} s_0 &= x_0 \\ s_i &= {\rm lerp}(s_{i-1}, \ x_i, \ \alpha), & i > 0 \end{aligned}
deltaTimeを使う
deltaTimeが可変の環境下においても、時間に対して恒常な結果が得られるようにするには、$ \alphaを指数関数を使って求める
$ \lambda > 0を定数として(大きいほど速く収束する)、
$ s_t = {\rm lerp}(s_{t-\Delta t}, \ x_t, \ 1 - \exp(-\lambda \Delta t))
Three.jsにおける実装
https://github.com/mrdoob/three.js/blob/37d6f280a5cd642e801469bb048f52300d31258e/src/math/MathUtils.js#L69-L74