Spec running statistics over millions of sensor readings

Vibe codingMedium25 min

Your task

Your Go analytics pipeline keeps a running mean and standard deviation for each sensor, over millions of float64 readings a day. A coding agent will write the code. Last time, a steady pressure sensor whose readings all sit near 101,325 pascals showed a standard deviation of 0 on some days and NaN on others.

Write the spec you would hand the agent.

What you know:

  • readings arrive one at a time, and you cannot keep them in memory
  • each sensor's stream is split across 16 shards, and the shard results are combined at the end of the day
  • faulty sensors sometimes send NaN or infinity
  • the dashboard shows the sample standard deviation

Then, in a few sentences: what does "compute the mean and standard deviation of the stream" produce on real data?