Public
Edited
Jun 19, 2024
2 stars
Insert cell
Insert cell
// x: prior probability
// y: probability of occurrence, given hypothesis is true
// z: probability of occurrence, given hypothesis is false
bayes = (x, y, z) => (x * y) / ((x * y) + z * (1 - x))
Insert cell
// you come home to find another person's underwear on your bed. is your spouse cheating?
cheating = bayes(0.04, 0.5, 0.05)
Insert cell
// chance you have breast cancer if you get a positive mammogram in your 40s
mammogram40s = bayes(0.014, 0.75, 0.1)
Insert cell
// probability the first 9/11 plane was a terrorist attack
first911 = bayes(0.00005, 1, 0.00008)
Insert cell
// probability the second 9/11 plane was a terrorist attack
second911 = bayes(first911, 1, 0.00008)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more