Debug School

ashley
ashley

Posted on

Implementing the NWS Heat Index: Polynomial Regression and Its Boundaries

Heat index is a classic example of a formula that looks like a physics equation but is actually an empirical regression. The NWS heat index is a polynomial fit to a table of apparent temperatures derived from a vapor-pressure model. Reimplementing it is a useful lesson in fitting-formula boundaries and in the dangers of applying a polynomial outside its calibration range.

The NWS regression

For air temperature T in °F and relative humidity R in percent (0–100), the Rothfusz regression is:

HI = -42.379 + 2.04901523*T + 10.14333127*R
     - 0.22475541*T*R - 6.83783e-3*T^2
     - 5.481717e-2*R^2 + 1.22874e-3*T^2*R
     + 8.5282e-4*T*R^2 - 1.99e-6*T^2*R^2
Enter fullscreen mode Exit fullscreen mode

A simpler formula covers T below about 80°F:

HI_simple = 0.5*(T + 61.0 + (T-68.0)*1.2 + R*0.094)
Enter fullscreen mode Exit fullscreen mode

The standard approach computes both and averages them when the regression result falls below 80°F, then applies low-humidity and high-humidity adjustments.

Worked example

T = 90°F, R = 70%:

Terms: -42.379 + 184.411 + 710.033 - 1413.197 - 55.386 - 268.604
       + 697.418 + 376.412 - 98.478 = 105.92°F
Enter fullscreen mode Exit fullscreen mode

That is roughly 16°F above the air temperature. At T = 100°F, R = 70% the same fit gives about 142.8°F, illustrating how aggressively the regression escalates near its upper range. The simpler formula at 90°F/70% gives 91.99°F; the full regression applies above 80°F.

Adjustment branches often missed

  • R < 13% and 80°F ≤ T ≤ 112°F: subtract ((13-R)/4) * sqrt((17-|T-95|)/17).
  • R > 85% and 80°F ≤ T ≤ 87°F: add ((R-85)/10) * ((87-T)/5).
  • T < 80°F: use the simple formula instead of the full polynomial.

Unit boundaries

The NWS coefficients are calibrated on °F and percent RH. Convert Celsius first: °F = °C * 9/5 + 32. Feeding °C into the polynomial produces nonsense that may still be in a plausible numeric range, making the bug easy to miss in unit tests that only check type and magnitude.

Edge cases

  • T below ~70°F or above ~125°F: the fit was not calibrated there; return the air temperature or a "not defined" signal rather than trusting the polynomial.
  • RH = 0 or 100: the adjustments have boundary conventions; clamp before the sqrt branch.
  • Heat index assumes shade and light wind. Full sun can add up to ~15°F; strong wind reduces the estimate.
  • Wet bulb globe temperature (WBGT) is a different index used for occupational heat stress — do not conflate them.

Verification and tool reference

For a worked heat-index calculation with the NWS branches and unit conversion spelled out, see the heat index calculator at Miryori.


Disclosure: The author leads content at Miryori, the free online calculator suite linked above. Educational arithmetic only, not safety advice.

Top comments (0)