importdefaultSourcefrom"./defaultSource";exportdefault(functionsourceRandomNormal(source){functionrandomNormal(mu,sigma){varx,r;mu=mu==null?0:+mu;sigma=sigma==null?1:+sigma;returnfunction(){vary;// If available, use the second previously-generated uniform random.if(x!=null)y=x,x=null;// Otherwise, generate a new x and y.elsedo{x=source()*2-1;y=source()*2-1;r=x*x+y*y;}while(!r||r>1);returnmu+sigma*y*Math.sqrt(-2*Math.log(r)/r);};}randomNormal.source=sourceRandomNormal;returnrandomNormal;})(defaultSource);