Show HN: Stochastic – JavaScript library for simulating stochastic processes
github.com
github.com
if (sum != 1){
return false;
where you're checking that the transition matrix sums to one across the rows, I think you can have problems due to finite precision. The sum can be epsilon different than unity. A reasonable check would be that abs(1-sum) < n*eps where eps is the floating-point precision (say, 4e-16).In fact, a strict check like this can sometimes be annoying because you might save or transmit the values in a JSON format with less than full precision.
Deleted comment
http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform#Ba...
For n > 1, consider Brillinger's book on time series.
Then, sure, bring along some FFT code.