Contents

Modeling a physical system

There is some fairly complicated math involved in convolution, so before starting on the math, let's start with an example to motivate the procedure (if you want to dig right into the math, you can go to the next page).

The problem we will consider is that of the interior temperature of an unheated building (this is actual data taken in February in southeastern Pennsylvania). The graph below shows the temperature external to the building (blue) and internal to the building (green). Note: a slight adjustment was made to the data for the purposes of this demonstration (see below for explanation if you are interested).

As you might expect the temperature inside varies significantly less that the temperature outside, and the internal temperature lags the external temperature somewhat. It seems reasonable to assume that the current internal temperature is some weighted average of past temperatures. Consider a weighting function that we'll call h(t). An example is shown below. We'll consider two possible weighting functions, an exponential decay, and a plain moving average. The exponential weighting function drops off rapidly, while the moving average weights all points equally. You can select either one:

Impulse Response Type (valid for t≥0)

$h(t)=\frac{1}{\tau}e^{-t/\tau}$
$h(t)=\frac{1}{\tau} \quad \quad (t<\tau)$

You can change the "width" of the function by adjusting τ (time constant for exponential, or window width for moving average).

Note: the height changes as well as the width because the area of the weighting function must equal 1 (see below for explanation if you are interested).

The blue function to the right is the external temperature. The red (transparent) function indicates how the weighting function contributes at a time, "t". The weighting function is shown for reference only, the actual height is shown on the previous graph. You can also click in any of the bottom three graphs to set the value of "t".

As an example try setting the time "t" to 8 days. The graph now shows the weighting function, reversed, and shifted over to t=8 seconds. The product is shown in magenta in the graph below that one (labelled "f(λ)·h(t-λ) vs λ"). The integral of the magenta line is the weighted average. You can see that, for exponential weighting, the points in the recent past have are accentuated while those further in the past are attenuated. Thus the points from the recent past contribute more to the integral.

The very bottom graph shows the external temperature (blue), the calculated internal temperature (i.e., the weighted average of the external temperature, and is shown in purple), and the measured internal temperature is shown in green. The weighted average is calculated as

$y(t)=\int_{-\infty}^{+\infty}{h(t-\lambda)\cdot f(\lambda)\cdot d\lambda}$

In this equation, f(t) is the internal temperature, h(t) is the weighting function, and y(t) is the weighted average. Note that the variable λ is just a dummy variable for integration and does not appear in the final result.

Things to try

• Increase the width of the weighting function (i.e., increase τ). Note that the calculated temperature gets smoother because the "average" is over a longer time period.
• Decrease the width of the weighting function (i.e., decrease τ). Note that the calculated temperature gets closer to the external temperature because the "average" is over a shorter time period.
• Try setting t=8 days, τ=4 days. The calculated internal temperature (i.e., the weighted average) is above 0° because the temperature in the recen past was mostly above 0°.
• Try setting t=18 days, τ=4 days. The calculate internal temperature (i.e., the weighted average) is below 0° because the temperature in the recent past was below above 0°.
• Try setting τ=1.5 days. The calculated internal and external temperature are almost equal after an initial startup transient .

Some minor points (you can probably skip this)

Input and output data must have equal averages

Because we are calculating the internal temperature as a weighted average of the external temperature, they should have the same average (so if the external temperature were constant, the internal temperature would settle at that same temperature). The measured internal and external temperatures are shown at the left. I adjusted them so that their averages were the same (since this was February in Philadelphia, I picked 0°). You can see it made little difference - the biggest change is that the internal temperature is a few degrees lower in the adjusted data (right graph).

The main reason the original internal temperature was higher is because this model neglects any heat input from solar energy, but assumes that the only thing that affects the internal temperature is the external temperature.

The area of the weighting function must equal 1

We define the weighted average as

$y(t)=\int_{-\infty}^{+\infty}{h(t-\lambda)\cdot f(\lambda)\cdot d\lambda}$

If the function to be averaged is a constant f(λ)=K, then

$y(t)=\int_{-\infty}^{+\infty}{h(t-\lambda)\cdot K\cdot d\lambda}=K\int_{-\infty}^{+\infty}{h(t-\lambda) d\lambda}$

Obviously we want the average of a constant to be equal to that constant, so we want the integral of the weight function to be equal to 1

$\int_{-\infty}^{+\infty}{h(t-\lambda) d\lambda}=\int_{-\infty}^{+\infty}{h(\lambda) d\lambda}=1$

(note that since the integral goes from -∞→+∞ the value of t is unimportant).

Initial Transient

Set the weighting function to an exponential with τ=1.5 days. If you look at the graph for calculated internal temperature, you will note that it does not agree with the measured internal temperature near t=0. This is because our calculation assumed that the internal temperature started at 0° at t=0 days, and the external temperature was 0° for t<0; see graph labeled "f(λ) = Ext T, …". This is known as a "zero state solution" (initial conditions are zero). In order to get a "complete solution" you need to add in the "zero input solution" that accounts for the initial temperature (i.e. set the calculated internal temperature to about 8° at t=0 (to match the actual internal temperature).

References

Replace