A world model that forecasts your room lets you know one number per step, but it doesn't give you a trust measure. This post gives the heater model one. Fit it eight times on resampled copies of the same log, and the spread between the eight forecasts is its doubt: over a degree on a night colder than anything it was trained on, a quarter of a degree where it has little to be unsure of. You will see that band drawn on the test room, a planner that reads its cold edge and refuses a plan the average of the eight would have accepted (that plan leaves the room cold in 75 runs of 200), and what the band cannot see however many copies you fit. The method is a three-line resampling function and four seconds of training.
The planner in the last post does what its model tells it, and its model gives it one number per step. On the question from 106, keep a room at minus four outside above 12 degrees for twenty steps with the fewest heater steps, the planner chose sixteen because the model said fifteen would not do. The true constants say fifteen is enough, with a tenth of a degree to spare, and a room with draughts under that plan dips below 12 in 75 of 200 runs. The model was right to want sixteen, and it was right by being six tenths of a degree pessimistic where it happened to matter. Nothing in it knew that the fifteen-step plan was close.
This post gives the model a way to say how sure it is. The method is an old one: fit the same model several times on slightly different logs and see how far the copies disagree. Then the planner is told the coldest of the copies' forecasts instead of one model's, so a plan that only works if the warmest copy is right gets refused. The code is in tools/heater_band.ts, and the playground fits five copies after the physics-shaped model and draws the band.
Eight models from one log
The log is the 4,800 rows from 104: eighty episodes of sixty steps, a thermostat, and a door nobody wrote down. The physics-shaped model from 107 is fitted on it once, as before, and reaches a loss of 0.179. Then it is fitted eight more times, each time on eighty episodes drawn from the eighty with replacement.
function resample<T>(items: T[]): T[] { return Array.from({ length: items.length }, () => items[Math.floor(rand() * items.length)]); } const members = Array.from({ length: 8 }, () => trainPhysics(resample(log), 3000)); Drawing with replacement means each copy sees about a third of the episodes not at all and some of them twice, so each copy is fitted to a slightly different account of the same room. This is the bootstrap, and the copies are an ensemble. Eight fits of three thousand epochs take four seconds in Node 23.
| member | loss | leak at field zero | heat | field's memory of itself |
|---|---|---|---|---|
| 1 | 0.164 | 0.106 | 1.18 | 0.24 |
| 2 | 0.166 | 0.103 | 1.17 | 0.20 |
| 3 | 0.180 | 0.104 | 1.17 | 0.20 |
| 4 | 0.175 | 0.098 | 1.16 | 0.17 |
| 5 | 0.163 | 0.121 | 1.19 | 0.26 |
| 6 | 0.172 | 0.104 | 1.16 | 0.15 |
| 7 | 0.177 | 0.098 | 1.16 | 0.13 |
| 8 | 0.181 | 0.092 | 1.15 | 0.13 |
The heater weight runs from 1.15 to 1.19 against a true 1.2, and the leak at a field of zero from 0.092 to 0.121. One model gives a leak of 0.102 and no idea whether 0.09 or 0.12 would have fitted as well. Eight models fitted on eight accounts of the room say it would.
Five of the eight learned the field upside down. Their doorLeak is negative and their uChange positive, so the door pushes their field to minus one where the other three go to plus one. Every one of them predicts the same leak when the door opens, because the product of the two is what act uses, and the training loop never had a reason to prefer one sign. The field is in the model's own units, as 104 said, and here each model has its own units. That rules out averaging the fields, and it is why the band below is made from forecasts and never from weights.
The band
A forecast is now eight forecasts. Each member watches the same room with its own field, and when asked what happens next it rolls its own weights forward from its own field. The band is the coldest to the warmest of the eight at each step.
class Band { models: PhysicsModel[]; constructor(ws: PhysicsWeights[]) { this.models = ws.map(w => new PhysicsModel(w)); } observe(s: State, a: Action, n: State) { for (const m of this.models) m.observe(s, a, n); } forecasts(s: State, heater: boolean[]): number[][] { return this.models.map(m => rollout(m, s, heater)); } low(s: State, heater: boolean[]): number[] { const f = this.forecasts(s, heater); return heater.map((_, i) => Math.min(...f.map(r => r[i]))); } } Here it is on the test room from 104, at minus four outside with the door open from step 10 to 20, which no model in this series has been trained on.
The real room from 22 degrees with the heater on. The thin ribbon is the eight models' one-step-ahead predictions. The three fans are their five-step forecasts, blind, from steps 5, 13 and 23. The room ends inside the first fan, a tenth of a degree above the second, and half a degree above the third.
| forecast from | real, five steps on | one model | coldest of eight | warmest of eight |
|---|---|---|---|---|
| step 5, door shut | 17.19 | 16.92 | 16.95 | 18.06 |
| step 13, door open | 2.65 | 2.45 | 2.19 | 2.58 |
| step 23, door just shut | 6.80 | 5.84 | 5.40 | 6.26 |
At step 5 the band is over a degree wide and the room is inside it. Minus four outside is ten degrees colder than anything in the log, and a leak the models disagree about by a few hundredths, multiplied by a gap of twenty degrees and compounded over five steps, is a degree. The one model's forecast sits at the cold edge, which is the pessimism 107 relied on, and the band says it was one opinion among eight.
At step 13 the band is four tenths wide and the room is a tenth above it. With the door open the models agree closely, because an open door drags the room towards outside plus five so fast that there is little left to disagree about.
At step 23 the band misses. The door shut two steps earlier, every member's field is still part of the way down from where the door put it, and every member forecasts a room leaking faster than it is. They all have the same observe step trained the same way on the same kind of log, so they all settle at the same speed, and the band is as narrow as if they knew. A band made by resampling shows the disagreements resampling can create. What the eight copies all get wrong together, it cannot see, and the slow field after a door is the clearest example in this room.
Where the models disagree
I had expected the band to be narrow where the log is dense and wide where it is thin. It is not quite that.
The width of the band after five steps with the heater on, from every room and outside temperature on a grid, with the door shut and with it open. Dark is narrow, light is wide. A dot marks a cell where the log has twenty or more rows within a degree. The band widens from bottom right to top left, with the gap between room and outside, and the log sits in the middle of that gradient rather than at its narrow end.
Over the 32 cells where the log has twenty or more rows nearby, the band is 0.52 degrees wide on average after five steps. Over the 139 cells where it has none, 0.80, with a maximum of 1.76 in the top-left corner, a warm room on a bitter day. That is the right direction, but the picture is a gradient along the diagonal, and the cells the log never visited at the bottom right are among the narrowest of all. A room at 6 degrees with 12 outside has no rows within a degree of it in the log, and a band 0.25 wide.
The reason is in the model's shape. Its change is (leak + doorLeak * field) * gap + heat, and the eight members disagree about the two leaks by a few hundredths and about the heater by a few hundredths. A few hundredths of leak times a gap of twenty degrees is a lot. A few hundredths times a gap of six is almost nothing, whatever the log said about rooms at 6 degrees. The band is wide where the weights the models are unsure about matter, and that follows the gap more than it follows the data. The shape carries the rest, as 107 said it did: a physics-shaped model is sure that a warm day with a cold room leaks inwards, because the shape says so, and no member can disagree.
With the door open the whole grid is narrower, for the reason the step 13 fan was narrow. The members agree about the open-door leak to within about a hundredth, and in any case a room with its door open heads for the same place whichever member you ask.
Given this shape, the band says which of the log's blind spots matter. For this room, cold days with the door shut matter and warm days do not. A model with a less committed shape, a neural network with a few hundred weights say, would disagree with itself far more at the bottom right of the grid, because nothing in it would insist that heat flows downhill. Its band would follow the data more closely, and would be wide at 6 degrees with 12 outside, where this room is in little doubt.
The planner, told the cold edge
The planner from 107 scores a schedule by rolling the model forward under it and charging a hundred points per degree short. The only change is what it is handed to roll forward. On the band it gets low, the coldest of the eight forecasts at every step, so a schedule is scored as if the most pessimistic member were right about each step.
const bandModel = (): Model => { const b = new Band(memberWs); return { observe: (s, a, n) => b.observe(s, a, n), predict: (s, h) => b.low(s, h) }; }; The cross-entropy search, the cost and the replanning are the same code, and the margin the planner keeps is now the gap between the coldest member and the mean, which is wide where the members disagree and nothing where they agree. The price is eight rollouts per schedule instead of one. A decision takes 4.2 milliseconds against 0.8.
Back to the 106 question first, by exhaustive search over all 1,048,576 schedules.
| model | heater steps | model's lowest reading | real room, lowest, mean of 200 | safe in 200 runs |
|---|---|---|---|---|
| the true constants | 15 | 12.10 | 12.08 | 125 |
| one model | 16 | 12.37 | 13.00 | 200 |
| the band, coldest of eight | 16 | 12.42 | 13.00 | 200 |
| the band, mean of eight | 15 | 12.38 | 12.08 | 125 |
The coldest edge picks sixteen, as the one model did. The mean of the eight picks fifteen, the true answer, and fails 75 times in 200, which is the thing I wanted a band to prevent. Run the fifteen-step plan through the band and its lowest point is at step 10, where the eight members say somewhere between 11.95 and 12.95. The plan is a coin toss on the model's own account, and the coldest edge refuses it on those grounds, where the one model refused it because it happened to say 11.90. Both refuse the plan, and the band's reason is the one that applies again on the next question.
The next question is the same one at seven outside temperatures, from the same warm start, with the heater on and the door shut.
| outside | true constants | one model | the band |
|---|---|---|---|
| −4° | 15 steps, safe in 164 | 15, safe in 164 | 15, safe in 164 |
| −2° | 12, safe in 105 | 13, safe in 196 | 13, safe in 196 |
| 0° | 10, safe in 184 | 11, safe in 200 | 11, safe in 200 |
| 2° | 7, safe in 100 | 8, safe in 199 | 8, safe in 199 |
| 4° | 5, safe in 174 | 6, safe in 200 | 6, safe in 200 |
| 6° | 3, safe in 188 | 4, safe in 200 | 4, safe in 200 |
| 8° | 1, safe in 189 | 1, safe in 189 | 2, safe in 200 |
The plans a planner makes from the true constants are the cheapest plans that work on a room without draughts, and on a room with them they fail somewhere between a twentieth and half the time. Any model that says the room is a little colder than it is does better than the truth here, which is uncomfortable but follows from scoring to the target and no further. The one model does that on five of the seven nights and matches the truth on the other two. At 8 degrees it picks one heater step, its forecast touches 12.00 exactly, and the real room fails 11 times in 200. The band picks two, because the coldest member says one step leaves the room at 11.9. At minus four the three agree on fifteen, and all three are short 36 times in 200; the coldest member's lowest reading is 12.22, which is above the line, so the band had no reason to refuse. The band's margin comes only from the members disagreeing, and at minus four they disagreed too little to change the answer.
An evening, again
The 200 evenings from 107 are the test bench for the replanning planner: forty steps from 14 degrees, 12 wanted until step 25 and 18 after, the same draughts for every controller. The thermostat has its lead tuned for the night, which is the best a thermostat can do and more than it is usually given. I added a fourth controller, the one model with half a degree taken off every forecast, which is a margin chosen by hand.
| outside | controller | heater steps | readings short |
|---|---|---|---|
| 3° | thermostat, lead tuned for 3° | 36.7 | 0.06 |
| 3° | planner, one model | 35.5 | 1.31 |
| 3° | planner, half a degree of margin | 36.9 | 0.38 |
| 3° | planner, the band | 35.8 | 1.09 |
| 5° | thermostat, lead tuned for 5° | 31.0 | 0.07 |
| 5° | planner, one model | 30.7 | 0.20 |
| 5° | planner, half a degree of margin | 32.4 | 0.01 |
| 5° | planner, the band | 31.2 | 0.16 |
| 8° | thermostat, lead tuned for 8° | 23.4 | 0.04 |
| 8° | planner, one model | 22.8 | 0.10 |
| 8° | planner, half a degree of margin | 24.4 | 0.00 |
| 8° | planner, the band | 23.1 | 0.04 |
The band trims the misses at a cost of a third of a heater step a night, and on the cold night it leaves most of them in place. The fixed half degree removes most of the misses at a cost of a heater step and a half, and on the mild night that is 7 percent more heating than the planner needed to keep a room that was never in doubt. The thermostat's degree of hysteresis costs about the same as the fixed margin on the cold night and less on the mild ones, because it only heats when the room is actually low.
The misses the band leaves come from draughts. These evenings run between 3 and 8 degrees outside with the room between 12 and 20, in the dense part of the grid, and the band there is about half a degree wide over a five-step forecast. The 1.3 readings a night the one model drops at 3 degrees are draughts: a plan the model says reaches 18.02 meets a gust and reads 17.95. No ensemble of models of the room can narrow that, because a gust is noise and the log holds nothing about it for the models to learn. The only thing to do about noise is to measure it and keep a margin for it, which is what the thermostat's hysteresis and the fixed half degree both are.
There are two kinds of not knowing here. One is what the model has not been shown, which the band measures and which planning around pays for only where it matters. The other is what the room will not tell anyone in advance, which the model's own residual on the log measures (the loss floor of 0.01 in 103 is the draughts squared) and which has to be paid for everywhere. The literature calls them epistemic and aleatoric, and they want different fixes. The 107 planner had neither margin, and the version in this post has the first.
With the door in play, the band changes nothing. All four controllers are level to within half a heater step and half a reading, as the thermostat and the planner were in 107, because with the door open the best any controller can do is heat and wait.
Where this came from
Fitting a model several times and reading the spread as doubt goes back to Efron's bootstrap in 1979, and the modern form for neural networks is the deep ensembles paper by Lakshminarayanan, Pritzel and Blundell, which found that a handful of networks trained from different starting points gave uncertainty as good as or better than the approximate Bayesian methods it compared against, and that the ensemble's disagreement grew on inputs unlike the training data. Putting that inside a planner is PETS, from Chua, Calandra, McAllister and Levine in 2018, which is the paper the planner in 107 was already most of. Its dynamics model is five networks, each fitted on a bootstrap resample of the data recorded so far, and its planner is the cross-entropy method with replanning every step. Where it differs from this post is in what it does with the five: it runs particles through the ensemble, each particle following one member, and scores a plan by the average over particles rather than the worst one. That is a less cautious use of the band than mine and a more honest one, since taking the coldest of eight is a rule with no probability behind it. For a heater, the cautious rule has the advantage of being explainable in a sentence.
Try it
In the playground door scenario, Train now has a fourth phase. After the physics-shaped model finishes, five copies of it start from its weights and train for six hundred epochs each on resampled episodes, which takes a few seconds. They start from the trained weights rather than from scratch so that the browser is not kept waiting for five full fits, and the script checks that this shortcut gives bands of the same width as the eight full fits: 1.24 degrees at step 5 against 1.11, 0.37 at step 13 against 0.39. On the evening bench the warm-started five land within a tenth of a reading of the eight.
The forecast chart on the right gains a ribbon: the five members' blind forecast from the chosen step, coldest to warmest, with the physics-shaped model's line through it. Drag the forecast slider across the room and the ribbon opens up on the cold, door-shut steps and closes on the open-door ones. The line under the chart says how wide the band is at the end of the forecast and whether the real room landed inside it. In the planning section a checkbox puts the planner on the cold edge of the band, and the summary line reports the heater steps and the misses either way. The playground uses Math.random where the script has a seed, so its numbers wander a little from the ones here. The tables above are in heater-band-days.csv, heater-band-questions.csv and heater-band-question.csv, and the grid in heater-band-grid.csv.
The band measures the model's doubt about the room's constants, which so far have not changed. The next post takes the model out of the simulation and into a real office for the first time. The one after that watches the gap between what the model predicted and what the room did, step by step, and asks when a residual that will not settle means a window is open or a valve has stuck, and how to set a threshold for that without false alarms.


