MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / strideSample

Function strideSample

scripts/fungrim/artifact-freshness.ts:55–61  ·  view source on GitHub ↗

Evenly spaced deterministic sample of `k` indices over [0, n).

(n: number, k: number)

Source from the content-addressed store, hash-verified

53
54/** Evenly spaced deterministic sample of `k` indices over [0, n). */
55function strideSample(n: number, k: number): number[] {
56 const indices = new Set<number>();
57 const count = Math.min(k, n);
58 for (let i = 0; i < count; i++)
59 indices.add(Math.round((i * (n - 1)) / (count - 1)));
60 return [...indices].sort((a, b) => a - b);
61}
62
63function main(): void {
64 const args = parseArgs(process.argv);

Callers 1

mainFunction · 0.85

Calls 2

addMethod · 0.65
roundMethod · 0.45

Tested by

no test coverage detected