MCPcopy Create free account
hub / github.com/DFin/Neural-Network-Visualisation / getRandomSample

Function getRandomSample

assets/main.js:114–120  ·  view source on GitHub ↗
(digit)

Source from the content-addressed store, hash-verified

112 sampleSize,
113 totalSamples,
114 getRandomSample(digit) {
115 if (!Number.isInteger(digit) || digit < 0 || digit > 9) return null;
116 const bucket = digitBuckets[digit];
117 if (!bucket || bucket.length === 0) return null;
118 const randomIndex = bucket[Math.floor(Math.random() * bucket.length)];
119 return this.getSampleByIndex(randomIndex);
120 },
121 getSampleByIndex(index) {
122 if (!Number.isFinite(index) || index < 0 || index >= totalSamples) return null;
123 const pixels = normaliseSlice(index);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected