Unlisted
Edited
Jul 25, 2024
Insert cell
Insert cell
Insert cell
Insert cell
viewof intensity = makeSliderWithValue("PPP intensity", 5, 20, 0.1, 10,"")
Insert cell
viewof M = makeSliderWithValue("Connection radius", 10, 25, 0.1, 20,"")
Insert cell
radius = 1
Insert cell
height = 600
Insert cell
viewof WIDTH = Inputs.text({ label: "Width (px):", value: 1000 })
Insert cell
function poissonSampler(width, height, intensity) {
var q = [];

for (var i = 0; i < Math.floor(PoissonProcess.sample(intensity* width* height/10000)); i++) {
q.push([Math.random()*width,Math.random()*height])
};

return q;
}
Insert cell
import {makeSliderWithValue} from "@kemper/code-snippets"
Insert cell
intensity2 = function makeSliderWithValue(name, inputMin, inputMax, inputStep, initialValue, units) {
const div = html`<input type=range min=${inputMin} max=${inputMax} step=${inputStep} style="width:75%"> <code style="color:"#686963";">${name}:</code> <strong><output></output></strong> ${units}`;
const range = div.querySelector("[type=range]");
const number = div.querySelector("output");
div.value = range.value = initialValue;
number.textContent = initialValue;
range.addEventListener("input", () => number.textContent = div.value = range.valueAsNumber);
return div;
}
Insert cell
PoissonProcess = require ('https://unpkg.com/poisson-process/dist/poisson-process.min.js')
Insert cell
d3 = require("d3")
Insert cell
color_palette = ["#db5461", "#686963", "#8aa29e", "#3d5467", "#f1edee"]
Insert cell
get_color = () => {
var rand = color_palette[(Math.random() * color_palette.length) | 0]
return rand
}
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