Skip to content

analyze

function analyze(
hdIn,
ldIn,
opts?): Analysis;

Defined in: passes/analyze.ts:189

Compute the rank and distance passes together, in a single sweep over pairs.

Costs one pass instead of two; the rank side additionally skips its square roots, since ranking only needs the ordering.

ParameterType
hdInPointsInput
ldInPointsInput
optsAnalyzeOptions

Analysis

import { analyze, trustworthiness, continuity, stress } from "@saehrimnir/sickle";
// `data` and `projection` are number[][] (or a DruidJS Matrix, or Vectors).
// One O(N²·D) sweep; every read-out below is then arithmetic on what it kept.
const a = analyze(data, projection);
trustworthiness(a.coRanking, 20); // 0.9659
continuity(a.coRanking, 20); // 0.9709
stress(a.moments).value; // 0.0807

Some accumulators are off by default because they cost extra. Ask for them here, not when reading the measure — reading one the pass was not told to collect throws an error naming the option it needs:

const b = analyze(data, projection, {
localK: [20], // per-point arrays, at these k
densityK: 20, // for densityPreservation
triplets: true, // for tripletAccuracy
ccaLambda: 1, // for curvilinearStress
});