Learning LabExplorable explanations
← All artifacts
Bayesian Inference

House Prices with MCMC

Forty houses, four unknown weights, and a Markov chain that wanders the whole posterior. Watch it converge, then predict a price not as one number but as a full distribution.

mcmcbayesianregressionuncertainty
LiveInteractive · drag, toggle, run it
Bayesian Inference · Sydney Property

House Price Prediction with MCMC

40 synthetic Sydney houses. Four unknown weights. MCMC explores the posterior over all of them simultaneously.

The Model
price = θ₀ + θ₁×size + θ₂×bedrooms + θ₃×distance + Gaussian noise
We don't know θ₀–θ₃. MCMC explores the 4D posterior surface to learn a distribution over each weight.
Price vs Size (sqm)
Each dot is a house. True coefficient: $7,500/sqm.
Price vs Distance from CBD (km)
Negative relationship. True coefficient: -$8,000/km.
True weights (hidden from MCMC)
Base price
$300k
Per sqm
$7,500
Per bedroom
$40,000
Per km CBD
-$8,000
Synthetic data · true weights are θ₀=$300k, θ₁=$7.5k/sqm, θ₂=$40k/bed, θ₃=-$8k/km