Why Your LLM Gets Sensor Averages Wrong: Five Time-Series Traps

Your AI agent returns a clean average on your sensor data, and it is probably wrong. Five time-series traps that change the number without raising an error, and a ten-minute check to run on your own data.
The number looks right. That is the problem.
You connected your AI agent to the historian, asked for last month's average power on line 3, and got a clean answer with two decimals. It is probably wrong, and nothing in the answer tells you so.
Sensor data breaks the habits that work on business tables. An LLM writing SQL or Python on raw points does what it does on sales rows: it sums, it averages, it groups by day. On time series, each of those steps hides a trap. Here are five that change the number without raising an error, with small illustrative examples you can rerun on your own data.
Trap 1: a zero is not a gap
A logger goes down for six hours. Depending on the pipeline, those hours show up as nulls, as missing rows, or as zeros.
- If the gap is stored as zeros, a pump that ran at 100 kW all day averages 75 kW. The answer is 25% off.
- If the rows are simply missing, a plain average of the remaining samples can be right or wrong, depending on what happened during the gap.
An LLM cannot tell the difference from the rows alone. The right move is to detect the gap, say it is there, and compute on the covered time only, or refuse to answer for that window.
Trap 2: the average of averages
You ask for the mean over two days. Day 1 has 1,440 one-minute samples at a mean of 50 kW. Day 2 has 60 samples, because the logger was down most of the day, at a mean of 80 kW.
- Average of the two daily averages: 65 kW.
- Mean over every sample actually recorded: 51.2 kW.
The first number is what a quick GROUP BY day followed by AVG gives you. It weights a day with one hour of data the same as a full day. When coverage differs between days, units or sites, averages must be weighted by time covered.
Trap 3: counters summed raw
Energy meters, run-hour counters and flow totalizers report a cumulative value. Three readings of 10,000, 10,120 and 10,250 kWh mean 250 kWh consumed, not 30,370 kWh.
An LLM that treats the column like any other value will sum it. A more careful one takes the difference between the last and first readings, and then meets the next problems: counters reset after maintenance, roll over at a maximum value, or jump when a meter is replaced. Consumption is the sum of the positive deltas, with resets and rollovers handled explicitly.
Trap 4: samples are not time
Many historians log on change (deadband or exception logging). A temperature sits at 20 °C for ten hours and gets one sample. Then it spikes to 90 °C for ten minutes and gets a hundred samples.
- Arithmetic mean of the samples: about 89 °C.
- Time-weighted mean over the 10 h 10 min: about 21 °C.
The arithmetic mean answers "what was the average sample", which nobody asked. The question was about time, so each value has to be weighted by how long it held. This is the trap that makes text-to-SQL answers look plausible and be wrong by a factor of four.
Trap 5: the day that lasted 25 hours
Plants run in local time. Databases often store UTC. When clocks go back in autumn, one local day has 25 hours; in spring, one has 23.
- A daily energy total on the 25-hour day comes out about 4% higher than a normal day, with no change on the machine.
- Grouping by UTC date instead of local date shifts every "daily" figure by the time-zone offset, which moves night shifts into the wrong day.
Ask your assistant to compare daily consumption around the clock change and see whether it mentions it.
The trap behind the traps: it only saw part of the data
Even when the method is right, an LLM can only reason on what reaches its context. On months of high-frequency data, the agent samples, truncates or pulls only the first rows a tool returns, and the answer silently covers a fraction of the period. In our benchmark on 77 heat pumps, the LLM alone still answered at 6 hours of history and went over its context limit from 12 hours. Past that point, any average it returns is an average of what it could fit.
How to check your AI agent in ten minutes
Take one sensor you know well and ask your assistant five questions:
- "What was the average value last week?" Then check it against a time-weighted mean you compute yourself.
- "Were there any gaps in the data last month, and how long?" A good answer lists them.
- "How much energy did this meter record last month?" The answer should come from deltas, not a sum of readings.
- "Compare daily totals for the week of the clock change." Look for the 23 or 25-hour day.
- Ask the same question twice in two new conversations. Do you get the same number?
If the answers disagree with your own calculation, the problem is not the model's intelligence. It is where the maths runs.
Where the maths should run
The fix is architectural: let the model understand the question and let a time-series engine compute the number. In Spocky, the engine runs every query and computes every figure on your data source, read-only, with functions built for time series: bucketing by time, deltas on counters, filling or flagging gaps. The model receives the question, a summary and the computed figures, never the raw data, and explains the result. The same question on the same data gives the same number, and you can see the points behind it. More on the setup in how to ask your SCADA and historian data questions from Claude, ChatGPT or Copilot.
Run the five checks on your own data with Spocky's free 30-day trial, no credit card.
FAQ
Why does my LLM give wrong averages on sensor data?
Usually because it treats time series like a table: it averages samples instead of time, averages daily averages with different coverage, sums cumulative counters or reads gaps as zeros. The query runs, so nothing flags the error.
What is a time-weighted average?
An average where each value counts in proportion to how long it held. It is the right default for sensors logged on change or at irregular intervals, where a plain mean of samples overweights the moments with many samples.
How should I compute consumption from an energy meter?
Take the sum of the positive differences between consecutive readings, and handle counter resets, rollovers and meter replacements explicitly. Never sum the raw readings.
Why do I get a different answer each time I ask?
When the model writes new code or samples different rows on each run, the result changes. Computing the figure in a time-series engine, outside the model, gives the same number for the same question and data.
Can I test this on my own data?
Yes. Spocky's free trial lasts 30 days, with no credit card, in your browser or from your AI assistant.
Get the next one by email
Monthly. AI on industrial time series.