Date: March 27 2020
Summary: An overview on how to use the exponential smoothing algorithm
Keywords: ##zettel #signalprocessing #noise #artifact #smoothing #window #julialang #archive
Not Available
The exponential smoothing algorithm is a recursive algorithm and is one of the more simple smoothing methods commonly used to remove small noise and motion artifacts from a discrete time series signal. However, it can be considered a "manual" algorithm due to having to manually determine a smoothing factor for it to work properly.
Per conversation with Post-Doc Researcher, Fredrik Bagge Carlson, another definition for the smoothing factor is the "forgetting factor". A bigger value for the forgetting factor results in forgetting the memory built into the algorithm faster and focusing more on recent inputs.
Also, this method is classified as a moving average filter!
The algorithm is very simple in which it is described as:
The variables are defined as follows:
* The raw signal sequence
* The smoothed output signal sequence
* Time (where $t > 0$)
* Smoothing factor (must be chosen such that $0 < \alpha <1$)
The weighted average in this case works when you take a portion of the current value x(t) from the original signal and a portion of the s(t -1) is summed together after being scaled by the forgetting factor. [Explanation thanks to Fredrik Bagge Carlson]
Each term in the sequence, , is counted as the weighted average of the current data point from the sequence and the prior smoothed statistic, .
There is no clear method for choosing the value of the smoothing factor
yields a smaller smoothing effect and "value" updating values more highly
yields a greater smoothing effect but does not respond greatly to recent updates
using Plots # IMPORT FOR PLOTTING
using LaTeXStrings # IMPORT TO ENABLE LaTeX FORMATTING
gr()
let
# Choose Smoothing Factor, α, And Input Values Over Which To Calculate
# Choose α: 0 < α < 1
input = 0:0.001:1
α = 0.05
# Generate Generic Signal - In This Case Sin(2Ï€)
signal = [sin(2 * pi * i) for i in input]
# Adding Random Noise To Function
noisy_signal =
[sin(2 * pi * i) + rand([-1, 1]) * round(rand(), digits = 2) for i in input]
# Filter The Signal Using An Exponential Smoothing Filter
exponential_signal::Array{Float32} = [noisy_signal[1]]
for i in 2:length(signal)
smooth_term = α * noisy_signal[i] + (1 - α) * exponential_signal[i-1]
append!(exponential_signal, smooth_term)
end
# Plot Signals
plot(
input,
noisy_signal,
label = "Noisy Signal",
title = "Example of Exponential Smoothing",
)
plot!(
input,
exponential_signal,
label = "Exponentially Smoothed Signal",
linewidth = 3
)
plot!(
input,
signal,
label = L"sin(2\pi)",
linewidth = 5
)
end
Zelko, Jacob. Exponential Smoothing. https://jacobzelko.com/03272020064312-exponential-smoothing. March 27 2020.