-1

I am working on a model describing a protein. Molecule may be found in few states, transitions from one state to another are described by matrix containing transition rates. Model can be resolved as set of ordinary differential equations giving nice numeric results (starting from adjacency matrix -> transition rate matrix -> Kolmogorow forward equations -> numeric integration). However, to get the stochastic nature of the process, I would like to use Monte Carlo method. As far as I know, the Gillespie algorithm is made for this. Are there any packages you recommend for this kind of task?

michal_2am
  • 211
  • 1
  • 3
  • 10
  • Hi, welcome to SO. This is a pretty specific question, not really about programming *per se*. Third result from the Google results page for `Gillespie algorithm` provides some hints: http://scicomp.stackexchange.com/questions/338/python-implementations-of-gillespies-direct-method If you want to know how to seed random numbers in Python use `numpy.random` or `random`. – Aleksander Lidtke Jun 29 '16 at 14:08

2 Answers2

0

You could just try using the random module and perform the Monte Carlo simulation yourself, using a random float for the values in your initial adjacency matrix. Just be sure to randomly select a number within the accepted range of what your matrix can take.

To iterate over the simulation, use a for or while loop, depending on how many simulations you want to run.

Peter Wang
  • 1,808
  • 1
  • 11
  • 28
0

Beside working with the random module as proposed by @PeterWang and create the matrices yourself, alternatively you can use the numpy module, which also provides random sampling. This way you can create random numbers in any matrix dimensions you prefer. Especially regarding your further tasks a module working with matrices numpy might be a good solution.

For more details, see reference of numpy.random

Sosel
  • 1,678
  • 1
  • 16
  • 31