Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Stochastic – JavaScript library for simulating stochastic processes (github.com/nathanepstein)
55 points by nepstein on Aug 8, 2014 | hide | past | favorite | 10 comments



At line 116:

   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.


Good call, thank you. Updated version has been republished.


Since the row has "n" entries, and errors can accumulate in each add, something like (n+2)*eps may be more appropriate. (I wrote a similar library in Matlab.)


Shameless plug: if you're looking for something similar with a little more practical use cases: https://github.com/jprichardson/stochasm which is a fork of the great https://github.com/heydenberk/stochator


[deleted]


It looks like you're referring to the (equivalent) polar form. I'm using the 'Basic Form'.

http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform#Ba...


That was a fast delete! I was trying to reply that the form in your code is detailed in the excellent book Simulation Modeling and Analysis by Law (previous editions by Law and Kelton. I'm sure there's a story there...)


Consider also continuous time, second order stationary of known power spectra, say, for dimension integer n > 0.

For n > 1, consider Brillinger's book on time series.

Then, sure, bring along some FFT code.


Awesome, going to use it in my trading bot. Thanks!


I want to see some demos using this!


Nice work Nathan!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: