Public
Edited
Sep 25, 2023
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { ternary } from "@fil/ternary-plot"
Insert cell
payoff = ([a, b, c]) => [
m[0] * a + m[1] * b + m[2] * c,
m[3] * a + m[4] * b + m[5] * c,
m[6] * a + m[7] * b + m[8] * c
]
Insert cell
sampleCoordinates = d3
.cross(d3.range(0.05, 1, 0.05), d3.range(0.05, 1, 0.05))
.map(([x, y]) => [x, y, 1 - x - y])
.filter(([, , z]) => z > 0)
Insert cell
quiver = sampleCoordinates.map(([a, b, c]) => {
// Compute scores
const [ax, bx, cx] = payoff([a, b, c]);

// Grow the population sizes
const alpha = 0.2;
let ap = a * (1 + ax * alpha);
let bp = b * (1 + bx * alpha);
let cp = c * (1 + cx * alpha);

// Normalize to 100%
const total = ap + bp + cp;
ap /= total;
bp /= total;
cp /= total;

return { a, b, c, ap, bp, cp };
})
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