Binomial Smoothing in Julia

Every experimental measurement in physics includes sources of noise. Of course, we try to minimize the sources of noise, but there is a limit to this ability (thermal noise, for instance, can be minimized, but not eliminated). Consequently, it often makes sense to smooth a data set to help reduce random noise in our data. One of the common methods is to use binomial smoothing.

A single pass of binomial smoothing applied to time series data {x} with N points from i=1 to i=N replaces x_i with

x_i = (x_{i-1} + 2x_i + x_{i+1})/4

The values of the first and last elements of the original time series are preserved if we extend the endpoints cleverly so that x_0 = x_1 - (x_2 - x_1) = 2x_1 - x_2 and x_{N+1} = x_N - (x_{N-1} - x_N) = 2x_N - x_{N-1}.

This smoothing amounts to weighting each point by the 2nd row in Pascal’s triangle (1 2 1) and dividing the result by the sum of their values (2^2 = 4). In this case, I consider the peak of Pascal’s triangle to be the zeroth row. If we execute another pass of binomial smoothing on the time series, this amounts to weighting the original data set with the 4th row (1 4 6 4 1) in Pascal’s triangle (sum = 2^4 = 16).

So, to execute N passes of binomial smoothing, we simple execute the (1 2 1) smoothing N times. This is more simply achieved using the algorithm of Marchand and Marmet: see Binomial smoothing filter: A way to avoid some pitfalls of least‐squares polynomial smoothing, Review of Scientific Instruments 54, 1034 (1983); https://doi.org/10.1063/1.1137498.

Because I have not found a Julia package that implements binomial smoothing, I have implemented the algorithm they describe in their 1983 paper and posted the code on GitHub at https://github.com/paulnakroshis/Smoothing.jl

The documentation illustrates the usage of the function, and shows several examples, including an interactive example which illustrates simultaneously the effect of the smoothing on the original time series data as well as the power spectrum of the data.

About PaulNakroshis

Professor of Physics at the University of Southern Maine.
This entry was posted in data analysis, Interactive, Julia, Smoothing and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.