Planetary-scale answers, unlocked.
A Hands-On Guide for Working with Large-Scale Spatial Data. Learn more.
Authors
Stochastic modeling is a method for forecasting outcomes that depend on chance. A stochastic model represents uncertain inputs as random variables with probability distributions, then simulates thousands of possible futures to give the range of results and the probability of each. Banks, actuaries, and epidemiologists use it, and insurers use it to estimate the losses a hurricane season could cause to every building in a portfolio. This article claims that a few thousand simulated years give a stable mean, and a 1-in-250 year loss needs far more than 1,000. A Monte Carlo simulation over every building in one county tests it below.
A random variable takes different values with defined probabilities, described by a probability distribution such as the normal, lognormal, or Poisson. The National Institute of Standards and Technology (NIST) and SEMATECH, a semiconductor industry consortium, publish the e-Handbook of Statistical Methods. It catalogs the common distributions and their uses.
Because the inputs vary, each run of a stochastic model produces a different result. One run is a single possible future, called a realization or sample path. Thousands of runs together form an output distribution, and that distribution is the answer.
A deterministic model returns the same output every time for the same inputs. A retirement projection that assumes a fixed 5% annual return is deterministic: $100,000 grows to about $163,000 in ten years, every time.
A stochastic version draws each year's return from a distribution with a 5% mean and a set volatility, the spread of yearly returns around that mean. One run ends at $120,000, another at $210,000. After 10,000 runs, the model reports the median outcome and the probability that the balance falls below a target.
Weather forecasting uses both approaches. The National Oceanic and Atmospheric Administration (NOAA) runs its High-Resolution Rapid Refresh (HRRR) weather model deterministically, one forecast per cycle. NOAA's Global Ensemble Forecast System (GEFS) runs 31 forecasts per cycle: one control and 30 perturbed with small random changes. It is documented in the GEFS version 12 paper by Zhou and colleagues (2022). The spread of those forecasts measures uncertainty.
Repeated random sampling is Monte Carlo simulation. Nicholas Metropolis and Stanislaw Ulam named and described the approach in The Monte Carlo Method (1949), from their work on neutron diffusion at Los Alamos. Metropolis, the Rosenbluths, and the Tellers followed with the Metropolis algorithm (1953), the root of Markov chain Monte Carlo. Hammersley and Handscomb collected the techniques in an early textbook, Monte Carlo Methods (1964).
The stochastic model is the set of distributions and rules. Monte Carlo simulation applies those rules to random draws and records each outcome. The error of a Monte Carlo average falls with the square root of the number of runs, so four times as many runs halve it. Estimates of the mean settle quickly. Estimates of rare outcomes, such as a 1-in-250 year loss, need far more runs, because only a few simulated years land in that tail.
A seed is the starting number of a pseudo-random generator. The same seed gives the same sequence, which makes a run reproducible. Apache Spark processes a table in slices called partitions. Its rand(seed) seeds an XORShiftRandom generator with the seed plus the partition index, from the xorshift family of random number generators George Marsaglia described in Xorshift RNGs (2003).
rand(seed)
A stochastic process is a sequence of random variables indexed by time or space, such as daily rainfall at a gauge or the price of a stock. Analysts group them by whether time and the state (the value the process takes) are discrete or continuous:
Markov chains move between states with probabilities that depend only on the current state. Richardson's stochastic weather generator (1981) models wet and dry days as a Markov chain. It then draws temperature and solar radiation based on whether the day is wet or dry.
Poisson processes count events that arrive independently at a constant average rate. The number of events in a year then follows a Poisson distribution. Catastrophe models and the Wherobots example below use it for annual event counts.
Brownian motion is continuous random movement with independent, normally distributed increments. Albert Einstein's 1905 paper on suspended particles gave it a physical model.
In physical risk, stochastic modeling is spatial. Every hurricane, flood, or wildfire has a location, a footprint, and an intensity at every point it touches.
Karen Clark described the Monte Carlo approach to insured catastrophe losses in A Formal Approach to Catastrophe Risk Assessment and Management (1986). Grossi and Kunreuther's Catastrophe Modeling: A New Approach to Managing Risk (2005) documents the structure that catastrophe models still share: hazard, exposure, vulnerability, and loss modules.
The hazard module is a stochastic event set: a catalog of simulated hurricanes, floods, earthquakes, or wildfires, each with an annual rate of occurrence. Model developers fit distributions to the historical record, such as the hurricane tracks in NOAA's HURDAT2 database, described by Landsea and Franklin (2013). They then sample tens of thousands of years of plausible events, including storms larger than any yet observed.
Each event has a hazard footprint: its peak wind speed, flood depth, ground shaking, or flame length across a grid. The model joins every footprint to the exposure, meaning the buildings and parcels in a portfolio with their construction and value. A vulnerability curve converts the intensity at each building into a damage ratio, the share of the building's value lost. Summing damage across buildings gives one loss per event. The losses listed by event and simulated year form the year event loss table.
Ranking the simulated years produces the loss distribution. Average annual loss (AAL) is the mean loss per simulated year. The exceedance probability (EP) curve and probable maximum loss give the probability that annual loss exceeds each value. The return period is the inverse of that probability. A loss with a 1% annual exceedance probability is the 100-year loss.
The open-source Oasis Loss Modelling Framework runs catastrophe models in this structure. The Federal Emergency Management Agency (FEMA) model Hazus applies the same hazard, exposure, and vulnerability chain to earthquakes, floods, hurricanes, and tsunamis. The US Forest Service's FSim fire simulator, described by Finney and colleagues (2011), models thousands of fire seasons with random ignitions and weather. Its burn probabilities are an input to Wildfire Risk to Communities. Analysts check simulated fire perimeters against burn scars mapped from earth observation data, such as the Sentinel-2 burn severity pipeline Wherobots ran on the Spokane firestorm. Flood models route each simulated storm's rainfall over a digital elevation model to produce depth grids.
Spatial statistics applies stochastic modeling to quantities that vary over space.
Random fields, kriging, and conditional simulation. A random field assigns a random variable to every location. Nearby values are more alike than distant ones, and the variogram measures how that similarity falls with distance. Danie Krige estimated gold grades on the Witwatersrand from nearby samples in 1951. Georges Matheron formalized the theory in Principles of Geostatistics (1963). He named the best linear estimate from nearby samples kriging in Krige's honor, as Noel Cressie recounts in The Origins of Kriging (1990). Kriging returns the expected value at each location, a smooth map. Conditional simulation draws many equally likely maps that match the measured values and the variogram. The spread across maps measures the uncertainty between samples. André Journel set out the method for mining in Geostatistics for Conditional Simulation of Ore Bodies (1974). Matheron's intrinsic random functions (1973) introduced the turning bands method for simulating fields.
Spatial point processes. A point process places events in space at random: storm touchdowns, wildfire ignitions, earthquake epicenters, buildings. The reference model is the homogeneous Poisson process, also called complete spatial randomness: events fall independently, at the same average density everywhere. Brian Ripley's second-order analysis of stationary point processes (1976) introduced the K function. It counts neighbors within distance r of each event and compares the count with the Poisson expectation to detect clustering or regular spacing. Analysts test significance by Monte Carlo. They simulate many Poisson patterns in the same area and check whether the observed K curve falls outside the envelope of the simulated curves. Baddeley and Turner's spatstat package (2005) implements these tests.
The hazard footprints in a catastrophe model combine both families: event locations from a point process, and an intensity field around each one.
WherobotsDB runs the hazard-to-building joins of a stochastic catastrophe model in SQL. It does not ship a catastrophe model. The query below is a toy example: a Monte Carlo simulation of a circular hazard over real buildings, with every random draw made in SQL.
The query reads these inputs:
buildings_building
divisions_division_area
range(0, 12)
range(0, 10000, 1, 1)
range(0, 120000, 1, 1)
The setup:
rand(101)
rand(102)
rand(103)
rand(104)
range()
-- Toy Monte Carlo: 10,000 simulated years of circular hazard footprints over Oklahoma County, OK. -- Fixed seeds (101 to 104) on single-partition range() tables make every run identical. WITH pois AS ( -- Poisson CDF for an average of 2 events per year, k = 0 to 11 SELECT k, SUM(EXP(-2.0) * POW(2.0, k) / FACTORIAL(k)) OVER (ORDER BY k) AS cdf FROM (SELECT id AS k FROM range(0, 12)) ), years AS ( SELECT id AS sim_year, rand(101) AS u FROM range(0, 10000, 1, 1) ), year_n AS ( -- Inverse-CDF draw: the event count is the number of k whose CDF lies below u SELECT /*+ BROADCAST(p) */ y.sim_year, COUNT(p.k) AS n_events FROM years y LEFT JOIN pois p ON p.cdf < y.u GROUP BY y.sim_year ), slots AS ( -- 12 candidate event slots per year: a uniform center in the county bounding box -- and a radius of 250 m plus an exponential draw with a 750 m mean SELECT id DIV 12 AS sim_year, id AS event_id, id % 12 AS k, -97.674 + 0.533 * rand(102) AS lon, 35.377 + 0.349 * rand(103) AS lat, 250 - 750 * LN(1 - rand(104)) AS radius_m FROM range(0, 120000, 1, 1) ), footprints AS ( SELECT s.sim_year, s.event_id, s.lon, s.lat, s.radius_m, ST_Buffer(ST_Transform(ST_Point(s.lon, s.lat), 'EPSG:4326', '+proj=utm +zone=14 +datum=WGS84 +units=m +no_defs'), s.radius_m) AS fp FROM slots s JOIN year_n y ON s.sim_year = y.sim_year AND s.k < y.n_events ), county AS ( SELECT geometry AS g FROM wherobots_open_data.overture_maps_foundation.divisions_division_area WHERE id = '27718581-7b60-42fb-b885-6d8cbf2a3699' -- Oklahoma County, Oklahoma ), buildings AS ( SELECT /*+ BROADCAST(c) */ b.id, ST_Transform(ST_Centroid(b.geometry), 'EPSG:4326', '+proj=utm +zone=14 +datum=WGS84 +units=m +no_defs') AS pt FROM wherobots_open_data.overture_maps_foundation.buildings_building b, county c WHERE b.bbox.xmin > -97.675 AND b.bbox.xmax < -97.140 AND b.bbox.ymin > 35.376 AND b.bbox.ymax < 35.727 AND ST_Intersects(c.g, ST_Centroid(b.geometry)) ), event_loss AS ( -- Year event loss table: buildings whose centroid falls inside each footprint SELECT f.sim_year, f.event_id, COUNT(*) AS loss FROM footprints f JOIN buildings b ON ST_Contains(f.fp, b.pt) GROUP BY f.sim_year, f.event_id ), annual AS ( SELECT y.sim_year, y.n_events, COALESCE(SUM(e.loss), 0) AS aep_loss, -- all events in the year COALESCE(MAX(e.loss), 0) AS oep_loss -- largest single event FROM year_n y LEFT JOIN event_loss e ON y.sim_year = e.sim_year GROUP BY y.sim_year, y.n_events ), ranked AS ( SELECT *, ROW_NUMBER() OVER (ORDER BY aep_loss DESC) AS aep_rank, ROW_NUMBER() OVER (ORDER BY oep_loss DESC) AS oep_rank FROM annual ) SELECT (SELECT COUNT(*) FROM buildings) AS buildings, COUNT(*) AS years, SUM(n_events) AS events, SUM(CASE WHEN n_events = 0 THEN 1 ELSE 0 END) AS years_without_event, ROUND(AVG(aep_loss), 1) AS aal_buildings, -- average annual loss MAX(CASE WHEN aep_rank = 5000 THEN aep_loss END) AS median_year, MAX(CASE WHEN aep_rank = 1000 THEN aep_loss END) AS aep_10yr, -- 1,000th worst of 10,000 years MAX(CASE WHEN aep_rank = 100 THEN aep_loss END) AS aep_100yr, MAX(CASE WHEN aep_rank = 40 THEN aep_loss END) AS aep_250yr, MAX(CASE WHEN oep_rank = 100 THEN oep_loss END) AS oep_100yr, MAX(CASE WHEN oep_rank = 40 THEN oep_loss END) AS oep_250yr, MAX(aep_loss) AS worst_year FROM ranked
One WherobotsDB query ran the whole simulation in 27 seconds, and three runs returned identical numbers. It drew 20,018 events in 10,000 years. 1,389 years had no event, close to the 13.5% a Poisson mean of 2 predicts. Average annual loss is 2,223.2 buildings, and the median year hits 593. Most years are mild, and a few severe years pull the mean up.
Aggregate loss sums every event in a year. The 1-in-10 year aggregate loss is 6,172 buildings, the 1-in-100 year loss 22,142, and the 1-in-250 year loss 31,915. Occurrence loss counts only each year's largest event. Ranked that way, the 1-in-100 and 1-in-250 year losses are 20,475 and 29,683. The worst year, 3931, hit 85,019 buildings. One 8.7 km footprint over south Oklahoma City hit 80,359 of them.
EXPLAIN FORMATTED prints the plan Spark will run. It joins the footprints to the building centroids with a broadcast index join, a spatial join that copies one side to every worker and indexes it. It has no Cartesian product, which would pair every footprint with every building. Each building is tested only against nearby footprints, out of 20,018 × 441,465 possible pairs. Swapping the final SELECT for SELECT * FROM annual returns the 10,000 yearly rows plotted below.
EXPLAIN FORMATTED
SELECT
SELECT * FROM annual
Splitting the 10,000 years into ten 1,000-year catalogs measures how far a smaller catalog drifts. The query reuses every common table expression (CTE), or named subquery, above:
-- Replace the ranked CTE and final SELECT above with: blocks AS ( -- Split the 10,000 years into ten independent 1,000-year catalogs SELECT sim_year DIV 1000 AS block, aep_loss, ROW_NUMBER() OVER (PARTITION BY sim_year DIV 1000 ORDER BY aep_loss DESC) AS rk FROM annual ) SELECT block, ROUND(AVG(aep_loss), 1) AS aal_buildings, MAX(CASE WHEN rk = 10 THEN aep_loss END) AS aep_100yr, -- 10th worst of 1,000 years MAX(CASE WHEN rk = 4 THEN aep_loss END) AS aep_250yr -- 4th worst of 1,000 years FROM blocks GROUP BY block ORDER BY block
Average annual loss ranges from 2,033.9 to 2,507.7 buildings across the ten catalogs, against 2,223.2 for the full run. The 1-in-100 year loss ranges from 18,303 to 26,796. The 1-in-250 year loss ranges from 25,937 to 37,720. A single 1,000-year catalog can miss the 1-in-250 year loss by almost a fifth.
A production model replaces each toy piece. A hurricane or hail event set replaces the circles, and intensity rasters sampled with RS_ZonalStats replace the binary hit. Vulnerability curves and insured values replace building counts. The join pattern stays the same, and WherobotsDB runs raster and vector in one engine; most stacks pick one. In How to score every building in a state for catastrophe risk, WherobotsDB joined 2,771,126 Overture buildings in Colorado to the Regrid parcels they sit on. It scored each one across five perils. It used the U.S. Forest Service Wildfire Risk to Communities 30 m raster, 403 million NOAA radar hail observations since 2016, and the FEMA National Flood Hazard Layer. The scores are published as the Colorado property risk explorer. A separate benchmark completed a statewide zonal statistics analysis across every building in Texas in 3 minutes 28 seconds.
Open problems.
What changes at scale. Each simulated event is a spatial object. Scoring it means intersecting its footprint with every building it touches, or sampling a raster under each building. A catalog of 10,000 events against 3 million buildings is 30 billion event-building pairs before pruning. Finding the pairs that overlap is a spatial join. Spatial partitioning, which puts nearby records on the same worker, and spatial indexing keep that join small enough to run. Jia Yu, Jinxuan Wu, and Mohamed Sarwat introduced that design for Apache Spark in GeoSpark (2015), now Apache Sedona. The same partitioned joins run each event set against national exposure, for every peril, model version, and climate scenario.
The AI models people use every day were trained on text, documents, databases, and the internet. Without a tool connection, they cannot compute which buildings sit inside a 100-year flood footprint. Through the Wherobots Model Context Protocol (MCP) server, geospatial AI agents run that query against the same tables an analyst uses.
The Oklahoma County run supports the opening claim: a stochastic model's mean settles within a few thousand simulated years, and its 1-in-250 year loss needs far more than 1,000.
Run a seeded Monte Carlo against every building in a county with a Wherobots free trial at cloud.wherobots.com.
Stochastic modeling is a way to forecast an uncertain quantity by treating its inputs as random. The model draws input values from probability distributions, runs thousands of times, and reports the range of outcomes and how likely each one is. A deterministic model returns a single answer for a fixed set of inputs.
A stochastic model is a mathematical model with at least one random variable among its inputs or rules. Each run produces a different outcome, called a realization, and the collection of many runs approximates the probability distribution of the result. Examples include the Black-Scholes option pricing model, Markov chain weather generators, and the stochastic event sets inside catastrophe models.
Monte Carlo simulation is the most common method for running a stochastic model. It draws random samples from each input distribution, computes the outcome for each draw, and repeats the process thousands or millions of times. The collected outcomes approximate the probability distribution of the result. Stochastic modelling is the broader idea. Monte Carlo, named by Metropolis and Ulam in 1949, is a technique for running a stochastic model.
A deterministic model produces the same output every time it runs with the same inputs. A stochastic model includes random variables, so each run produces a different output. Many runs together form a probability distribution. A fixed 5% interest projection is deterministic. A projection that draws each year’s return from a distribution is stochastic.
Stochastic processes are commonly grouped by whether time and the state are discrete or continuous. A Markov chain has discrete time and discrete states. An autoregressive time series has discrete time and continuous states. A Poisson process has continuous time and discrete states. Brownian motion has continuous time and continuous states.
The terms overlap, and many authors use them interchangeably. Probabilistic modeling is the broader category: any model that represents uncertainty with probability distributions. Stochastic modeling usually refers to models of random processes that evolve over time or space, solved by simulating many sample paths.
Yes. Black and Scholes (1973) model the stock price as geometric Brownian motion, a continuous-time stochastic process with lognormal returns. For a European option the model has a closed-form solution, so no simulation is needed. Options whose payoff depends on the price path are priced by Monte Carlo simulation of the same process.
A stochastic event set is a catalog of simulated catastrophes, such as hurricanes, floods, earthquakes, or wildfires, each with an annual rate of occurrence and a hazard footprint. Catastrophe models run the event set against buildings and policies to produce loss distributions, average annual loss, and exceedance probability curves.
It depends on the statistic. The mean settles after a few thousand runs, because Monte Carlo error falls with the square root of the number of runs. Tail statistics need far more: a 1-in-250 year loss estimated from 1,000 simulated years is the 4th worst year. In a WherobotsDB example with a fixed random seed over Oklahoma County, ten 1,000-year catalogs gave 1-in-250 year losses from 25,937 to 37,720 buildings, against 31,915 from all 10,000 years.
Conditional simulation generates many equally likely maps of a spatial variable, such as ore grade or rainfall, that match the measured values at sample locations. The maps also match the variogram, which measures how similar values are at a given distance. Kriging gives one smooth best estimate. Conditional simulation gives a set of equally likely maps, and their spread measures the uncertainty between samples. Journel described the method for ore bodies in 1974.
In finance, stochastic modeling prices options and projects asset returns and retirement savings. Insurers use it for reserving and catastrophe risk, and epidemiologists use it to forecast outbreak spread. Other uses include queues and inventory in operations, mineral and groundwater uncertainty in geostatistics, and ensemble forecasts and weather generators in weather and climate science.
What is a Geofence? How Geofencing Works, With Examples
A geofence is a virtual boundary that triggers an action when a device enters or leaves it. How geofencing works, its uses and limits, and a test on ship data.
What is Map Matching? GPS Traces, Methods and Examples
Map matching places each GPS record on the road a vehicle drove. How it works, nearest-road snapping vs hidden Markov models, and a test on Ann Arbor drives.
Geospatial Big Data: Why Analytics Is Hard to Scale
Teams struggle to scale geospatial analytics for five reasons: data volume, mixed formats, many coordinate systems, spatial joins and pipeline upkeep.
share this article
Awesome that you’d like to share our articles. Where would you like to share it to: