Difference in Graph and Map Marker Data

Overview

While using the PurpleAir map, you may notice that the values on the graph do not match those on the Map Markers. This is due to differences in the types of averages being displayed.

The average used on the graph is a true average, while the average used on the Map Markers is a weighted moving average. This means that, instead of re-calculating the simple average every time a new entry is created, the average is run through a different formula. We will synchronize these values in the future.

Note: This only applies to averaged PurpleAir data. Real-time data will match on both the graph and the Map Markers.

How is This Calculated?

First, we subtract the current average divided by the total number of data entries from the current average. We then add the value of the latest data entry divided by the total number of data entries.


The formula, in code, is as follows:

avg -= avg / n
avg += new_entry / n

Key Terms:

  • “avg” is the current average
  • “n” is the total number of data entries
  • “new_entry” is the latest entry the device has reported.

When a new entry is appended, the oldest stored entry is deleted. This means that the total number of data entries (n) will remain the same.


Weighted Moving Average
This formula results in an estimation of what the true average is. While it is only an approximation, it is much less server intensive to compute than calculating the simple average for every sensor on the map. This approximation will trend toward the true average, but is never able to reach it.

True Average
The data displayed on the graph is a true average (i.e., a simple average using every applicable data entry). The true average is accurate and not an estimation.

Our Plans

We are working to synchronize the values in the future. The Map Markers will display true averages instead of the weighted moving averages they currently display.

1 Like