Freesteel Blog » The exponential decay curves are nice, shame about the theory

The exponential decay curves are nice, shame about the theory

Tuesday, October 21st, 2014 at 1:36 pm Written by:

To make up for my disorganization with the data collected at my house (in that it got lost, was not frequently sampled enough and didn’t happen over the winter), I got this lovely temperature sequence from megni to analyze for my exponential decay theory which took a reading inside their cottage every 60 seconds.


My theory is that by fitting exponential decay curves to the data I would get some invariant values relating to the fabric of the building that would change when you improved its insulation characteristics (eg draught-proofing a window).

The first step is to chop of this data into the sections where the temperature is dropping down. It took a while to get some working code, but it came like this:

gw = 30   # half an hour
sampleseqs, sampleseq = [ ], None
for i in range(gw, len(samples):
    vd = samples[i-gw][1] - samples[i][1]  # positive if past temp higher
    if vd >= 0:
        if not sampleseq or vd >= mvd:     # restart seq at bigger difference
            sampleseq = samples[i-gw:i]
            mvd = vd
    elif sampleseq:
        sampleseq = None


Now all these sections of declining temperatures are cut out, we can plot them aligned on the left, like so:

And now it’s a matter of picking each section and fitting an exponential decay curve to it, like so:

That one doesn’t fit so well, so I fitted the curve in a piecewise linear fashion on overlapping two hour sections (advanced by one hour at a time in this diagram).

Sadly, the exponential values are all over the place. We can guess that the outside temperature is declining through the night, which is why the lower limit temperature is going down, but this messes with the exponential decay value considerably. If the outside temperature was accelerating upward (its rate of going down was slowing) as it would be at the start of the night due to most of the cooling happening early on, then this will bend the curve upwards and cause the exponential decay value to be larger relative to what it will be later in the night when the temperature is more constant.

Which is all very well, but a narrative explanation (ie BS) isn’t any good when I really need some numbers.

Here’s plotting the time (compressed) against the lower limit temperature vL, which looks like there’s a decline in the night time each day:

And this is plotting the exponential decay factor b against vL (b is always less than 0):
Not a great correlation, but it sort of shows that the exponential decay constant is lesser (closer to zero) when the temperature is low.

So, these aren’t great exponential decay fits, unless you account for the limit temperature changing, which is going for a third order effect (fitting curves is second order as it requires 3 points relating to second differential, fitting lines is first order as it requires 2 points relating to first differential).

Might be worth a try. And I should do it now I’m here, except I’ve been at this since early this morning.

But first, how am I fitting these exponential decay curves?

Well, here’s the simple linear regression calculated for the curve v = exp(b t + a) + vL, given vL and a sequent sq = [ (t, v) ]

n = len(sq)
sx = sum(t  for t, v in sq)
sx2 = sum(t*t  for t, v in sq)
sy = sum(math.log(v - vL)  for t, v in sq)
sxy = sum(t*math.log(v - vL)  for t, v in sq)
b = (sxy n - sx sy) / (sx2 n - sx sx)
a = (sy - b sx) / n

How do I find vL?

Well, I run this calculation for the two half sequences sq0, sq1 = sq[:len(sq)/2], sq[len(sq)/2:], and calculate b0 and b1 for each of them.

I need to pick a value of vL where b0 = b1.

By differentiating b with respect to vL you can solve for delta_vL in:

b0 + (db0/dvL) delta_vL = b1 + (db1/dvL) delta_vL

then add it to vL, and it converges pretty quickly.

1 Comment

  • 1. mike replies at 22nd October 2014, 1:52 am :

    i have noticed that curve in life, get excited about something and then interest starts to dwell in a repeating curve of spikes and dwells maybe something will stick

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>