histogram algorithm
-
[typescript] histogram algorithmPrograming/javascript 2019. 11. 26. 13:54
LINK const histogram = (data: any, size: number = 1) => { const length = data.length; let min = data[0]; let max = data[1]; data.forEach((item: number) => { if (item max) max = item; }); const bins = Math.ceil((max - min + 1) / size); const histogram = new Array(bins); for (let i = 0; i < bins; i++) histogram[i] = 0; for (let i = 0; i < length; i++) histogram[M..