Intuition for Convolution
A convolution is the amount of an overlap area of one function f as it is shifted over another function g at a given time offset.
Example using discrete valued functions
Let’s say we are transforming a certain function f(t) by passing it through a filter g(t) to get the output h(t):
f(t) -> [ g(t) ] -> h(t)
Say f(t) has the following values for t = [1, 2, 3, 4, 5] -> f(t) = [1, 2, 3, 4, 5], and
say g(t) has the following values for t = [1, 2, 3] -> g(t) = [3, 2, 1]
Now the question is what is the value of h(t) at a specified time t.
To find the value of h(t) at any time t, let's start with following -
Idea:
Imagine flipping the f(t) with respect to time values, because that is
what it looks like when it enters the filter [g(t)]
Now let's start here,
->| start of time (t)
[1, 2, 3] -> time
f(t) = [5, 4, 3, 2, 1]
g(t) = [3, 2, 1]
To calculate the values of h(t), let’s line up the values of f(t) and pass them through the values of g(t)
At t = 1
g(t) 3 2 1
f(t) 5 4 3 2 1
Total value 3 <-(3x1) = 3
At t = 2
g(t) 3 2 1
f(t) 5 4 3 2 1
Total value 6 2 <-(3x2)+(2x1) = 8
At t = 3
g(t) 3 2 1
f(t) 5 4 3 2 1
Total value 9 4 1 <-(3x3)+(2x2)+(1x1) = 14
At t = 4
g(t) 3 2 1
f(t) 5 4 3 2 1
Total value 12 6 2 <-(3x4)+(2x3)+(1x2) = 20
At t = 5
g(t) 3 2 1
f(t) 5 4 3 2 1
Total value 15 8 3 <-(3x5)+(2x4)+(1x3) = 26
At t = 6
g(t) 3 2 1
f(t) 5 4 3 2 1
Total value 10 4 <-(2x5)+(1x4) = 14
At t = 7
g(t) 3 2 1
f(t) 5 4 3 2 1
Total value 5 <-(1x5) = 5
Just by sliding to any t = n, we can find the value of h(t) by calculating the value of overlapped “area” at t = n.
Now the value h(t) = conv(g(t), h(t)) at any time t is as follows
g(t) * f(t) = h(t)
[3 2 1] * [1 2 3 4 5] = [3 8 14 20 26 14 5]
| | | | | | |
Time - - - - - - - - - > 1 2 3 4 5 6 7
Note:
So far we have been doing a simple summation of terms as our functions are discrete. If we are dealing with continuous functions, the integral as a limit of a summation would come into play.
If you have Matlab, please see https://www.mathworks.com/matlabcentral/fileexchange/4616-animated-convolution
Credit: The above example is based on the Intuitive Guide to Convolution @ Better Explained