import type { INorm } from "@thi.ng/random" ; export const preseed = ( n , scale , rnd ) => { const state = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { state [ i ] = rnd . norm ( scale ) ; } return state ; } ; export const sum = ( src ) => src . reduce ( ( sum , x ) => sum + x , 0 ) ; export function * interleave ( a , b ) { const src = [ a [ Symbol . iterator ] ( ) , b [ Symbol . iterator ] ( ) ] ; for ( let i = 0 ; true ; i ^= 1 ) { const next = src [ i ] . next ( ) ; if ( next . done ) return ; yield next . value ! ; } }