I think it's a lot simpler than we have been thinking. The 30 (or 15 or 5) mile Whr/mi number is no more that the watt hours consumed in driving the last 30 (or 15 or 5) miles divided by 30 (or 15 or 5). The display shows consumption vs range and displays perhaps 100 points. Thus each point represents 0.3 or 0.15 or 0.05 miles. The value displayed at a point could be nothing more than the watt hours consumed in traveling the previous 0.3, 0.15 or 0.05 miles.

Let's say you sit at a stop light for 3 minutes (0.05 hr) with the heater going at 1 kW and the display in 5 mi setting. When the light turns green you take of and cover 0.05 miles using 0.05*400 = 20 Whr to move the car that far but the total energy consumption over that first 0.05 miles includes 0.05*1000 = 50 Whr for the heater for a total of 70. Dividing by 0.05 miles would give 70/0.05 = 1400 Wh/mi - off the scale. In the next 0.05 miles another 20 Whr would be consumed by the motor plus another 1000*0.05/25 = 2 Whr for the heater assuming 25 mph and heater power still at 1 kW. Dividing by 0.05 we have 22/0.05 = 440. If the display were set to 30 mile range the first computation after the green light would come at 0.3 miles. The energy used to move the car would be 0.3*400 = 120 Whr which, when added to the heater energy at the stop light plus1000*0.3/25 = 12 Whr for the heater assuming it is still drawing 1 kW and the average speed is 25 mph would give a total of 182. Dividing by 0.3 gives 607 Wh/mi. In the next 0.3 miles the energy used would be again 120 for the traction plus another 12 for the heater for a total of 132. Divided by 0.3 that's 440 Whr/mi.

Now we don't see any single point spikes at 1400 followed by an adjacent point at 440 so it is clear that some sort of smoothing over a few points is taking place. This could be boxcar or leaky integrator. As the latter is easier to implement I'd guess it's that but only Tesla knows. This would also support the feelings of some that more recent data is more heavily weighted than older but note that this smoothing only effects the appearance of the display from which one is only intended to get an impression of what has been going on. The average is clearly a simple block average obtained by dividing the power used in the last, e.g., 30 miles by 30.

There is a question here as to what gets counted as energy used in the last 30 miles. Clearly we want the average to be useful for prediction of achievable range and so it should include power taken from the battery in operating the car. For example, when if we pre warm the car in the parking lot of a motel with no destination charger the energy taken from the battery, IMO, should be coubted. But should we count energy used for that when we are connected to a charger? In that case it comes from the charger and should not be counted. But what I think doesn't matter. What counts is what Tesla actually did.

When I started to write this I was making it more difficult than it ought to be and came up with the following which, as I have done it, I'm going to include as it might be of interest.

As the car is going down the road the battery must supply energy to:

1)Push the car against a force (drag) that is proportional to the square of the airspeed i.e. to (s + w)^2 where s is the ground speed and w the wind speed component in the direction of travel. In time ∆t the car travel s*∆t and as energy is force times distance this energy is Cd*(s^3 + 2*s^2*w + s*w^2)∆t. Cd is a drag coefficient which is a function of (s + w) but lets assume it is constant here to make things simple.

2)Change the kinetic energy of the car by m*a*s*∆t where m is the mass of the car and a is the acceleration which is negative when you take your foot off the accelerator.

3)Change the potential energy of the vehicle by m*g*G*s*∆t in which g is the acceleration due to gravity and G is the grade as a fraction (G - 0.02 for a 2% grade).

4)Run the cabin and battery heaters, the coolant pump, the windshield wipers, the window motors, the seat motors the radio, and charge your cell phone. If the power demanded by all those things is W then the energy taken from the battery in time ∆t is W*∆t.

Dividing through by ∆t we get the total power demand on the battery, ∆E/∆t

P = ∆E/∆t = Cd*s^3 +2*Cd*s^2*w + Cd*s*w^2 + m*a*s + m*g*G*s + W

We don't want, for the display, ∆E/∆t. We want ∆E/∆x where x is the distance traveled. That's easily obtained from

∆E/∆x = (∆E/∆t)/(∆x/∆t) where clearly ∆x/∆t = s, the ground speed of the vehicle. So

∆E/∆x = P*∆t/∆x = Cd*s^2 + 2*Cd*s*w + Cd*w^2 + m*a + m*g*G + W/s = Wh/mi

This makes it clear that your main strategy for extending range is slow down and wait for headwinds to die down if they are forecast.

It also shows that if you stop for any reason that the instantaneous Wh/mi becomes infinite if there is any electric consumption other than that of the traction motors which, as discussed earlier, is not a problem for the hypothecated display calculation because ∆x is never 0 when a computation is done.