The 2024 Developer Survey results are live! See the results

# Tag Info

### How do I reliably generate random numbers in Python distributed across multiple nodes?

To the best of my knowledge, Numpy does not support independent streams. Indeed, getting independent streams from the Mersenne Twister (Pythons RNG) is notoriously difficult although it can be done. ...
• 2,503

### How to traverse $\{0, 1, \dots, 2^n-1\}$ in random order?

A random number generator will give you random numbers that you can tweak to be between zero and 2^n and consequently it will allow you to sample random locations ...

### How do I reliably generate random numbers in Python distributed across multiple nodes?

It is not a problem if one processor generates a number that has already appeared on a different processor. It would, however, be a problem if the two generated whole sequences that are similar. This ...
Accepted

### Running a Random Number generator in parallel? Will this speed up a computation?

The random number generator is rarely the limiting factor in computational science. RNGs are usually quite simple and fast, a few dozen instructions, really. If you are doing anything even remotely ...

### Simple Monte Carlo in C++, result dependent from seed

As noted in the comments by Kirill, the y-axes of the two plots are very different. And if they are rescaled accordingly, the boxes will certainly look very similar, if not identical. Therefore, it ...
• 8,702

### Producing random variables with exp. distribution, but I need to use a constant! (python)

The inverse transform sampling method is generally used to allow sampling uniform random variables and then transforming them such that the result has the suitable distribution. To do this you need an ...
• 485

### How good are current implementations of rand() in C?

But these seem pretty old criticisms of the rand function This may be a nitpick, but I want to point out what I think is a flaw in this logic. Compilers are often extremely conservative about ...
• 11.4k

### How to generate Poisson-distributed random numbers quickly and accurately?

If you can use C++11 you can use the built-in Poisson distribution ...
• 465

### How to evaluate "quality" of set of attainable random permutations

To permute a list, there is no need to enumerate the n! possibilities. Shuffling the list should be sufficient. Pseudo code (from wiki article) for shuffling would be ...
• 165

### How to evaluate "quality" of set of attainable random permutations

You can do some spot checking. Testing for all $n!$ possibilities is impractical, but you can make some unit tests to make sure that after doing sufficiently many shuffles certain properties of the ...
• 12.4k

### Is there a better way to do run time analysis than this?

Welcome to SE SciComp. First of all, I would suggest using Jupyter so that you have access to IPython and its nice timing magics (see %time and %timeit magic function). These magics take into account ...
• 6,159

### How to plot random points in 3 dimensions in order to calculate volume of a torus through Monte Carlo integration

You don't need to plot a torus to calculate its volume. Moreover you can analytically compute the volume integral and it's even on wikipedia. With Monte Carlo you can use rejection sampling to figure ...
• 2,277
1 vote
Accepted

### Random access (quasi-?)random sequence

There's a paper by Gruenschloss about enumerating Sobol points falling within some elementary intervals: https://github.com/lgruen/sample-enum This is used in pbrt with the global sampler in order to ...
1 vote
Accepted

### Which type of RNG can I use together with a MT RNG in a simulation?

Maybe I've found a solution myself, hope that someone knowledgable can check if this is correct! I can use a second MT19937 with the same seed where I jump ahead the state of the generator at the ...
• 111
1 vote
Accepted

### Trying to do a 2D random walk for a particle

You are only moving in one direction for each axis. ...
• 68
1 vote
Accepted

### Introductory reference on bit-twiddling?

Bit-twiddling is sometimes used as part of the numerical algorithms that are apropos for this site (e.g., hardware implementations of the Fast Fourier Transform, simulation of quantum computers, etc.)....
• 4,004
1 vote
Accepted

1 vote

### How do I reliably generate random numbers in Python distributed across multiple nodes?

This exact problem (not generating the same random number sequences) is described in John D. Cook's blog post Random number generator seed mistakes. The solution is simply to ensure that processes ...
• 111

Only top scored, non community-wiki answers of a minimum length are eligible