Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let me simplify the problem I am trying to solve so that the issue I face is highlighted.
Say, I want to generate $n$ samples of a Gaussian random variable. I have a script (say random.m) that does it. I have Mathematica installed on a node with $4$ cores. I ssh into it and run $4$ instances of "math -script random.m" The idea is that I generate $\frac{n}{4}$ per instance. Now, my actual script is a little more complicated, with other variable names, etc. One of the features of Mathematica is that the value of a variable is not restricted to a notebook (unless one does so explicitly).
My question basically is: when I run 4 instances of a program, do they run completely independently of one another?
(Even though I have the same variable names in random.m, the variables themselves are random. So, I don't want any cross-talk amongst the four instances.)

share|improve this question
There are different meanings of independence here. *If you want statistical independence on each node, you can invoke your own different SeedRandom[blah] on each node; they would be independent anyway - but you can control it yourself on each node. *If you seek to run your code faster by running it on 4 independent copies of mma ... then you may be disappointed in this instance ... because, as far as I can tell, mma's Random number generator will automatically take advantage of as many cores as you have available ... so if you run 4 copies of Mma, you still only have 4 cores available. – wolfies Mar 30 '14 at 17:28
up vote 1 down vote accepted

Yes, they run independently, as they are independent processes. But Mathematica takes the random seed from the system time, so if you start several independent processes at the same time, they will likely all generate the same sequence of random numbers. (When I tried this they did.)

It sounds like you should use Mathematica's parallel tools instead, which is likely to be much more convenient, and it does take care of this problem. It also does parallelization by launching multiple kernel processes.

share|improve this answer

Each instance of the kernel has no contact with other instances (unless there are explicitly shared variables).

Thus, in your case, they are independent.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.