Questions tagged [random-number-generation]

Questions on the algorithms for and uses of (pseudo)random number generators in scientific computing.

67 questions
16
votes
1 answer

How can I determine the period of my pseudo-random number generator?

Suppose I'm using a linear congruential pseudo-random number generator (PRNG). Given a seed $x_0$, the multiplying factor (a), the shift factor (c) and the modulus factor (m), how can I determine the period of my PRNG? Do I determine it by…
Paul
  • 12,045
  • 7
  • 56
  • 129
5
votes
1 answer

How to assure that a number only contains a certain range of digits?

Say I would like to generate a pseudo-random number, which only contains the digits 1, 4, 7 (this is arbitrary). My first guess would be to create and array "147" and create random numbers in the range [0..2] and use these numbers as an index into…
JohnDoe
  • 201
  • 1
  • 7
4
votes
1 answer

Why my linear congruential generator generate low quality random numbers?

I am implementing an arbitrary bits random number generator (in [$0,2^n$)) and also want to ensure that the generator always generate unique numbers until all possible numbers generated, so I implement it using LCG (I also considered the linear…
user62783
  • 151
  • 2
2
votes
0 answers

Applications where random number generation is a speed bottleneck

Pseudorandom numbers are used massively in Monte Carlo methods, e.g. in physics simulations. The fastest random number generators, such as the xoroshiro or xorshiro families by Vigna (see eg here) are extremely fast, taking approximately three CPU…
Lorents
  • 131
  • 1
2
votes
2 answers

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

To randomly permute a list one has to select one of $n!$ possibilities, which quickly goes outside of the capabilities of conventional PRNGs. Even Mersenne Twister fails with a list of length greater than 2080 entries, and probably fails much…
sh1
  • 141
  • 4
2
votes
1 answer

Difference between true & pseudo random numbers

I recently heard that in Linux, /dev/random and /dev/urandom are pseudo random number generators but not true random number generator. So I am curious to know the difference between pseudo & true random number? In other words What is the difference…
Pandya
  • 121
  • 4
1
vote
0 answers

approximate Poisson disk / blue noise sampling

Poisson disk or blue noise sampling consists of finding a random, maximal set of points $\{x_i\}$ in a domain $\Omega$ such that $\|x_i - x_j\| \ge r$ for some fixed radius $r$ and for all $i$, $j$. There are several algorithms for efficient blue…
Daniel Shapero
  • 10,263
  • 1
  • 28
  • 59
1
vote
2 answers

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

Here, $n$ could be a few hundreds, or even thousands, so it is not possible to pregenerate a list of $$\{0, 1, \dots, 2^n-1\}$$ and shuffle it. Because it is traversal, no number should be visited twice. I want the process of generating the next…
user62783
  • 151
  • 2
1
vote
0 answers

Random Number Generation-full period

How can i demonstrate that a LCG has full period? Is there a way to demonstrate it or do I just need to check the parameters(a, c, m)?
1
vote
0 answers

Generate gaussian random field in spherical polar coordinates

I would like to generate an isotropic gaussian random field described by a power spectrum $P(k)$ on a 3D grid which represents spherical polar coordinates (i.e., the angular separation between pixels at each slice in the radial direction is equal…
myseun
  • 53
  • 3
0
votes
1 answer

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

This question arises from my attempt to mix two different RNGs. I'd like to mix them choosing the best of the two according to the operations I need to carry out to achieve better performance. I'm restricted to use a Mersenne Twister (MT19937) RNG…
Tortar
  • 111
  • 4
0
votes
0 answers

Numpy random generator seed choice

I am new to understanding pseudorandom number generators and sometimes feel daunted by them. For some time I have used the following approach in my work: In one file, I'd have import numpy as np np.random.seed(1) my_random_process() In another…
user196574
  • 133
  • 4
0
votes
0 answers

How to limit the output value of an Linear Congruential Generator, but still maintain an extremely long period?

Let us suppose that I have a full cycle LCG, following the standard equation Hence, as it has a full cycle, it will have a period of m, and will output values ranging from 0 to m. However, I want to limit the output values to somewhere between 0…
0
votes
1 answer

Generating pseudorandom sequences based on measured sequences

I'm looking for an algorithm to generate discrete-time pseudorandom sequences based on other sequences I already have that would be used to train the algorithm. More specifically, I have some time-based discrete-time measurements of some real-live…
siritinga
  • 203
  • 1
  • 6
0
votes
2 answers

Maths calculations for randomly generated numbers don't match computed averages

Ok, It was hard to explain my problem in the title. I hope it made enough sense to peak the curiosity of some of you. What I've been trying to do is find the relationship between the amount of random numbers generated (n) and the probability that an…