Public
Edited
Feb 8, 2023
Paused
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function pdf(counts) {
let sum = counts.reduce((s, a) => s + a, 0);
sum = sum == 0 ? 1 : sum;
return counts.map((a) => a / sum);
}
Insert cell
function cdf(counts) {
let sum = 0;
let a = counts.map((x) => (sum += x));
sum = sum == 0 ? 1 : sum;
return a.map((x) => x / sum);
}
Insert cell
function Shannon(counts) {
let p = pdf(counts);
return -p.reduce((s, x) => s + (x == 0 ? 0 : x * Math.log(x)), 0);
}
Insert cell
function Tsallis(counts, q) {
let p = pdf(counts);
let s = p.reduce((s, x) => s + x ** q, 0);
return s == 0 ? 0 : (1 - s) / (q - 1);
}
Insert cell
function Masi(counts, r) {
let h = Shannon(counts);
return 1 + (1 - r) * h > 0 ? Math.log(1 + (1 - r) * h) / (1 - r) : 0;
// : Math.log(-1 - (1 - r) * h) / (1 - r);
//return Log(1 + (1 - r) * h) / (1 - r);
}
Insert cell
function Hill(counts, q) {
let p = pdf(counts);
let s = p.reduce((s, x) => s + x ** q, 0);
return s ** (1 / (1 - q));
}
Insert cell
function Sine(counts, q) {
const sin = Math.sin;
const PI = Math.PI;
let p = pdf(counts);
let s = p.reduce((s, x) => s + sin(PI * x), 0);
return s;
}
Insert cell
function Normal(mu, sigma, x) {
return (
(1 / (sigma * Math.sqrt(2 * Math.PI))) *
Math.exp(-0.5 * ((x - mu) / sigma) ** 2)
);
}
Insert cell
function Cauchy(x0, gamma, x) {
return gamma / Math.PI / ((x - x0) ** 2 + gamma ** 2);
}
Insert cell
arr = {
const n = 256;
return new Uint8ClampedArray(n * n * 4);
}
Insert cell
Insert cell
Insert cell
Insert cell
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