6
votes
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 ...
4
votes
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 ...
4
votes
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 ...
3
votes
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 ...
3
votes
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 ...
2
votes
How to generate Poisson-distributed random numbers quickly and accurately?
If you can use C++11 you can use the built-in Poisson distribution
...
2
votes
How to generate Poisson-distributed random numbers quickly and accurately?
I found the answer from the book Numerical Recipes in C, but unfortunately the code in that book is copyrighted. So, I re-derived a similar code that is slightly different but does the same thing.
...
2
votes
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
votes
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 ...
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 ...
Community wiki
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 ...
1
vote
Accepted
Trying to do a 2D random walk for a particle
You are only moving in one direction for each axis.
...
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.)....
1
vote
Accepted
Why does this line of code give a flat distribution?
You are omitting to mention what GRNDM actually does (and that turns out to be not so obvious to find on the internet): It returns random numbers in the interval $[...
1
vote
How good are current implementations of rand() in C?
Though the question is about C, I still consider the following information regarding C++11 relevant.
In C++11, <random> was added that is both designed to fix ...
1
vote
Weighted Monte Carlo Integration
What about dividing the interval $[0,0.6]$ in sub-intervals $[x_i,x_{i-1}]$ so that in each one the function value has the same order of magnitude?
For example you could choose $x_0 =0$, $x_{m}=0.6$
$$...
1
vote
How to traverse $\{0, 1, \dots, 2^n-1\}$ in random order?
Use a trivial $n$-bit counter, and encrypt it using a block cipher in any configuration other than ECB or CTR, starting with the least-significant bits as your first block so the small change ...
1
vote
Why my linear congruential generator generate low quality random numbers?
This is simply how LCG works.
You can reduce the problem for your application by simply exclusive-or-ing some of the high bits over some of the low bits in the output (but do not use this modified ...
1
vote
Implementation of stochastic cellular automata
Not sure if I understood correctly, but I think that if your parameters µ and $\Delta t$ are constant during all the simulations and for all nodes, you can generate ...
1
vote
Accepted
Generate a set of random x,y,z numbers, with a minimum difference between them, between defined limits
So one thing you can do is implicitly represent a structured region, like a 3D rectangular volume, as a set of chopped up sub-volumes where each sub-volume automatically enforces the spatial ...
1
vote
Accepted
Using physical parameter as a Gaussian random variable in a simple Poisson problem
In the loop over your instances of 100 random values for $k$, you could write the value for $k$ into a file, and call your finite element code; the finite element code could then open the file, read ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
random-number-generation × 67monte-carlo × 9
python × 8
statistics × 7
algorithms × 5
parallel-computing × 5
fortran × 5
c × 5
probability × 5
random-sampling × 4
reference-request × 3
molecular-dynamics × 3
numerics × 2
c++ × 2
performance × 2
petsc × 2
floating-point × 2
random-walk × 2
finite-element × 1
optimization × 1
matlab × 1
matrix × 1
computational-physics × 1
simulation × 1
discretization × 1