(array: any[])
| 34 | * library as the random generator. |
| 35 | */ |
| 36 | export function shuffle(array: any[]): void { |
| 37 | let counter = array.length; |
| 38 | let temp = 0; |
| 39 | let index = 0; |
| 40 | // While there are elements in the array |
| 41 | while (counter > 0) { |
| 42 | // Pick a random index |
| 43 | index = Math.floor(Math.random() * counter); |
| 44 | // Decrease counter by 1 |
| 45 | counter--; |
| 46 | // And swap the last element with it |
| 47 | temp = array[counter]; |
| 48 | array[counter] = array[index]; |
| 49 | array[index] = temp; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | export type DataGenerator = (numSamples: number, noise: number) => Example2D[]; |
| 54 |
no outgoing calls
no test coverage detected
searching dependent graphs…