Sensor fusion of altitude data
GPS altitude data is notoriously inaccurate.
GPS data can provide accurate horizontal position information within a meter or two, but is not as accurate in vertical altitude. GPS.gov provides extensive performance reports on GPS accuracy, and indicates that the daily average horizontal position error for 2019 was 1.09 - 1.24 m, but the daily average vertical position error for 2019 was almost double at 1.45 - 2.12 m. GPS is designed to be accurate to less than 9 m horizontally on average, but can have vertical errors as large as 37 m, or 120 feet, in the worst case. So, generally, the vertical position error is somewhat worse than the vertical position error, but occasionally much worse. As noted in the Little Lies my GPS Told Me post, accurate altitude data plays a key role in calculating precise distances on steep alpine slopes.
Apple provides developers with a barometric altimeter that can be used to supplement the GPS radio altitude data. The barometric altimeter does not provide an absolute measurement of altitude, but it does provide good relative changes in altitude. Typical relative altitude data from a barometric altimeter sensor on a smart phone or smart watch is accurate to ± 0.25 m. So, what we would like to do is combine, or fuse, the barometric altitude data with the GPS radio altitude data. This is accomplished through sensor fusion.
Inverse variance weighting is a mathematical technique used in sensor fusion for combining uncertain data from two different sensors to create an improved measurement estimate. Any real world measurement will have error associated with the measurement. If you performed a repeated series of measurements using the same sensor, you would observe that the data clusters into a normal distribution with a mean value μ, and a standard deviation σ, or error, about the mean. Inverse weighting is a method of aggregating different measurements with random error in a way that minimizes the total error of the weighted value.