Correction, I messed up with last night's version, so here's a correct one.

function polarBoxMuller pLength, pMean, pStd
   put 2 ^ 32 -1 into tMax
   repeat plength div 2
      repeat
         put (random(tMax) / tMax) * 2 - 1 into x
         put (random(tMax) / tMax) * 2 - 1 into y
         put x * x + y * y into r
         if r <> 0 and r <= 1 then exit repeat
      end repeat

      put sqrt( -2 * ln(r) / r) into d
      put pMean + (x * d) * pStd & comma after tList
      put pMean + (y * d) * pStd & comma after tList
   end repeat
   return char 1 to -2 of tList
end polarBoxMuller

Best,

Mark
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to