Public
Edited
Mar 15
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const margin = 10;
const width = 800;
const height = width / 2;

const svg = d3
.create("svg")
.attr("width", width + 2 * margin)
.attr("height", height + 2 * margin);
const g = svg
.append("g")
.attr("transform", `translate(${margin}, ${margin})`);

g.append("line")
.attr("stroke", "black")
.attr("stroke-width", 2)
.attr("x1", 0)
.attr("y1", height)
.attr("x2", width)
.attr("y2", height);

const pvalue = (p) => Math.atan(Math.sqrt(-2 * s * s * Math.log(1 - p)));
const N = 4;
const pValues = [0.5, 0.9, 0.99, 0.999];
for (const p of pValues) {
const theta = pvalue(p);

const cosTheta = Math.cos(theta);
const sinTheta = Math.sin(theta);
const radius = 0.9 * height;

const dx = radius * sinTheta;
const dy = radius * cosTheta;

g.append("path")
.attr("stroke", "none")
.attr("fill", "oklch(85% 0.17 95)")
.attr("fill-opacity", 1 / (N - 1))
.attr(
"d",
`M ${width / 2} ${height} l ${dx} ${-dy} a ${radius} ${radius} 0 0 0 ${
-2 * dx
} ${0} z`
);
}

return svg.node();
}
Insert cell
import { build_samples } from "@mcmcclur/adaptive-plotter"
Insert cell
viewof beta = Inputs.range([1e-8, 1], {
label: "beta",
transform: Math.log,
invert: Math.exp
})
Insert cell
{
let gamma = 1 / Math.sqrt(1 - beta * beta);
let min = 2 * gamma;
let range = 1000;
let curve = build_samples(
(x) =>
(2 * (beta * beta * x + Math.sqrt(1 + beta * beta * x * x))) /
(1 - beta * beta),
-gamma - range,
-gamma + range,
{ N: 100 }
);
let taylor = build_samples(
(x) => min + (beta * beta * (x + gamma) * (x + gamma)) / gamma,
-gamma - range,
-gamma + range,
{
N: 100
}
);
let right = build_samples(
(x) => (2 * beta * x) / (1 - beta),
0,
-gamma + range,
{ N: 100 }
);
let left = build_samples(
(x) => -(2 * beta * x) / (1 + beta),
-gamma - range,
0,
{ N: 100 }
);
let plot = Plot.plot({
width: 600,
height: 600,
y: { domain: [min, min + (beta * beta * range * range) / gamma] },
marks: [
Plot.line(curve, { stroke: "steelblue" }),
Plot.line(taylor, { stroke: "red" }),
Plot.line(right, { stroke: "yellow" }),
Plot.line(left, { stroke: "yellow" }),
Plot.ruleX([-gamma]),
Plot.ruleY([min]),
Plot.axisX({ y: min }),
Plot.axisY({ x: -gamma })
]
});
return plot;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more