A disclaimer up front: this will be the first of a number of postings on this subject. I apologise if they seem somewhat disjointed, it is probably a good reflection of the state of my mind right now. The final posting will summaries all of the experiments in this series, so if you don’t want to follow along just wait for the final summary.

**Euler’s Method**

Currently, we are estimating WBGT using Euler’s Method. Euler’s Method is a very simple algorithm for estimating values. In very simple terms, we take a function that depends on some variable, *x*, and we try to come up with an estimate of *x* where by the function returns a value that is suitably close to *x*. In psuedocode it looks like the following:

// set up with: f(x) = some function of x GOAL: make the LHS ~= RHS // estimation initial estimate of x := xi while True: xj = f(xi) if isGoodEnough(xj): // i.e. xi ~= xj return xi else: xi = improveEstimate(xj)

By using a good method for improveEstimate(), Euler’s Method will quickly *relax* down to a reasonably accurate value. We are using this approach to estimate the wet bulb temperature for Bernard’s model fro indoor WBGT.

**The Problem**

Euler’s Method is an iterative method. It is actually quite fast, because the *improveEstimate* method relaxes the value of *Tw* in relatively few iterations (< 20). However, we need to run this iteration ~ 3 million times per year. The cumulative effect is that it takes anywhere from 5 – 10 minutes to calculate WBGT each year. I hear what you are saying, “5 – 10 minutes a year is fine!”, but it’s not really. I am running these calculations constantly throughout my project, and it is incredibly limiting to have to wait this long for the results of a simple experiment. Even more importantly, the whole process of loading annual data into the database takes exactly:

TotalTime = Time(calculateWBGT) + Time(everything else)

where Time(calculateWBGT) >> Time(everything else)

The WBGT calculation **dominates** 90 % of the process. If I can improve this, then it would be a huge win.

I am also not convinced that out termination case (the method by which we determine isGoodEnough()) is all that accurate. I think there is a fair amount of *‘fudge’* in it and that the accuracy depends on the relative values on Ta and Td initially.

**Extrapolating WBGT**

Using Euler’s Method I have graphed each intermediate iteration and found that the function is *as good as* linear. This makes me think that we could accurately extrapolate Tw from a known function. Extrapolation on curves is inherently inaccurate, and usually involves some really cool modeling techniques using something like the Taylor series. However, extrapolating along a linear function is trivial. *If* we can assume a near-linear function, then I predict that we can accurately forecast Tw.

In my initial experiments I have found the following:

- Near perfect fit (Δ Tw < 0.1) for many inputs
- Reasonable fit (Δ Tw < 0.5) for ALL 2011 and 2010 data
- Small subset of very poor fit (Δ Tw > 1.0).
- Poor fit occurs when Td < 0, or when there is a large difference in the initial values of Ta and Td

This looks promising, but leaves me with a few questions:

- 2011 and 2010 data does not have ANY Td < 0. So why do the earlier years? Is this reasonable?
- 2011 and 2012 fits are ALL excellent Δ Tw < 0.5. Why are these two years so uniform?
- Poor fit occurs when Ta >> Td, what is going on here? I need to isolate these cases and compare the iterations in Euler’s Method to the Extrapolation.

If this works out, then there will be no need for iteration and the calculation times will be constant and significantly faster. I will discuss ongoing experiments in future posts.

EDIT: in some cases it is taking more than 50 iterations to estimate relax Tw. This takes a lot of time, and also correlates to the data that doesn’t fit with the extrapolation method.

LikeLike