← All examples
15

Canonical Grid model

Reproducible Election Forecast

Seeded poll aggregation, uncertainty draws, uniform swing, seat conversion, and win probability.

Scale
Medium
Source
15-election-forecast.grid
Length
27 lines
Collection
Forecasting & decisions
Level
Intermediate
Runtime
Shipped modules
Version
1.0.0

Watch it in Grid

See this model in motion.

Watch the model respond in the product, then inspect the exact source and checkpoints on this page.

Companion film

The forecast repeats itself

Change one poll and watch exact forecast probabilities and seats update while the same seeded draws repeat across every resolve.

46 secGrid 0.63.2
Open film page

What this model gives you

A reproducible polling model with weighted aggregation, 32 fixed-seed uncertainty draws, uniform national swing, district conversion, and an inspectable forecast summary.

25 min to study · Source reviewed 2026-08-26

Continue with guided practice

What to notice

  • Weighted poll aggregation
  • Seeded uncertainty draws
  • Uniform-swing seat conversion
  • Reproducible simulation evidence

Requirements

  • Grid 0.61 with shipped shared/politics.gs and shared/socsci.gs
  • RAND_SEEDED and NORM.INV functions
  • No connector or network

Expected checkpoint

A known state for this walkthrough.

With the shipped politics and social-science modules, the four authored polls and weights, and seeds 101 through 132. The deterministic algebraic outputs below are source-derived; the exact seeded win fraction is deliberately left unclaimed until a runtime receipt is recorded.

Weighted poll
0.4970454545…F1
National swing
-0.0029545455…C7
Adjusted districts
[0.557045…, 0.527045…, 0.507045…, 0.487045…, 0.457045…, 0.437045…]F8
Projected seats
3 of 6F10
Win probability
A reproducible multiple of 1/32C6; exact value awaits a runtime receipt
01 · Aggregate

Weight polls by effective sample size

soc.weighted_mean combines four estimates with their declared weights. Keep F1 visible so every simulation and district result points back to the same public poll estimate.

02 · Draw

Give every uncertainty draw a stable seed

The comprehension maps seeds 101 through 132 through RAND_SEEDED and NORM.INV. The seed list is model data, so the forecast can be replayed exactly by a compatible runtime.

03 · Convert

Apply one national swing to every district

C7 measures the poll against 50 percent. pol.uniform_swing applies that delta to each baseline share, after which F10 counts districts above the authored winning threshold.

04 · Receipt

Verify seeded outputs instead of copying a plausible probability

A canonical receipt should pin the runtime build, record all 32 draws or their digest, assert C6 and F10, and replay the same seeds in optimized mode before promoting the forecast as runtime-certified.

15-election-forecast.grid
MODEL "Reproducible Election Forecast"
DESCRIPTION "Seeded poll aggregation, uncertainty draws, uniform swing, seat conversion, and win probability."
VERSION "1.0.0"
AUTHOR "Grid Team"
TAGS "canonical", "portable", "politics", "forecast", "simulation"

USE "shared/politics.gs" AS pol
USE "shared/socsci.gs" AS soc

# Poll estimates and effective sample-size weights.
A1 = [0.48, 0.51, 0.49, 0.50]
A3 = [800, 1200, 900, 1500]
F1 = soc.weighted_mean(A1, A3)
F2 = 0.025

# Fixed seeds make the canonical Monte Carlo model reproducible.
A6 = [NORM.INV(RAND_SEEDED(seed), F1, F2) FOR seed IN 101..132]
C6 = COUNTIF(A6, ">0.5") / 32
C7 = F1 - 0.5

# Baseline district shares and uniform-national-swing seat conversion.
F6 = [0.56, 0.53, 0.51, 0.49, 0.46, 0.44]
F8 = MAP(F6, share => pol.uniform_swing(share, C7))
F10 = COUNTIF(F8, ">0.5")
A40 = `poll={F1} win_probability={C6} projected_seats={F10}`

END MODEL