Questions tagged [prng]

PRNG - Pseudorandom number generator, A pseudorandom number generator (PRNG), also known as a deterministic random bit generator (DRBG),[1] is an algorithm for generating a sequence of numbers that approximates the properties of random numbers.

See more about PRNG on wikipedia.org

232 questions
117
votes
5 answers

What's the origin of this GLSL rand() one-liner?

I've seen this pseudo-random number generator for use in shaders referred to here and there around the web: float rand(vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } It's variously called "canonical", or "a…
Grumdrig
  • 16,588
  • 14
  • 58
  • 69
71
votes
4 answers

differences between random and urandom

I'm trying to find out the differences between /dev/random and /dev/urandom files What are the differences between /dev/random and /dev/urandom? When should I use them? when should I not use them?
fernandohur
  • 7,014
  • 11
  • 48
  • 86
47
votes
3 answers

SecureRandom with NativePRNG vs SHA1PRNG

I need to generate cryptographically strong random numbers and byte arrays. For this purpose, I'm using Java's SecureRandom class. But I'm not sure to choose which PRNG algorithm in terms of their cryptographic strength. Which of the following…
ovunccetin
  • 8,443
  • 5
  • 42
  • 53
30
votes
4 answers

Random number in range with equal probability

This might be more Math related than C#, but I need a C# solution so I'm putting it here. My question is about the probability of random number generators, more specifically if each possible value is returned with an equal probability. I know there…
Matthew
  • 24,703
  • 9
  • 76
  • 110
25
votes
11 answers

True random number generator

Sorry for this not being a "real" question, but Sometime back i remember seeing a post here about randomizing a randomizer randomly to generate truly random numbers, not just pseudo random. I dont see it if i search for it. Does anybody know about…
goldenmean
  • 18,376
  • 54
  • 154
  • 211
21
votes
1 answer

Distributions and internal state

On Stackoverflow there are many questions about generating uniformly distributed integers from a-priory unknown ranges. E.g. C++11 Generating random numbers from frequently changing range Vary range of uniform_int_distribution The typical solution…
manlio
  • 18,345
  • 14
  • 76
  • 126
20
votes
10 answers

Do stateless random number generators exist?

Is there a difference between generating multiple numbers using a single random number generator (RNG) versus generating one number per generator and discarding it? Do both implementations generate numbers which are equally random? Is there a…
Gili
  • 86,244
  • 97
  • 390
  • 689
18
votes
2 answers

Picking A, C and M for Linear congruential generator

I am looking to implement a simple pseudorandom number generator (PRNG) that has a specified period and guaranteed no collisions for the duration of that period. After doing some research I came across the very famous LCG which is perfect. The…
Dave
  • 7,283
  • 12
  • 55
  • 101
17
votes
9 answers

Random Number Generator in CUDA

I've struggled with this all day, I am trying to get a random number generator for threads in my CUDA code. I have looked through all forums and yes this topic comes up a fair bit but I've spent hours trying to unravel all sorts of codes to no…
zenna
  • 9,006
  • 12
  • 73
  • 101
16
votes
1 answer

Working ONLY with /dev/random in Java

I have a HRNG that feeds /dev/random in Debian Wheezy. It's fast, so blocking will not be a problem. Now, in my Java code I want to ensure that I use the entropy in /dev/random and ONLY that entropy. I have no interest in using anything out of…
user3335193
  • 163
  • 1
  • 5
15
votes
3 answers

Mersenne twister warm up vs. reproducibility

In my current C++11 project I need to perform M simulations. For each simulation m = 1, ..., M, I randomly generate a data set by using a std::mt19937 object, constructed as follows: std::mt19937 generator(m); DatasetFactory…
Ilio Catallo
  • 3,152
  • 2
  • 22
  • 40
13
votes
3 answers

Cryptographically secure unique id

I want to generate cryptographically secure unique uuids using php. uniqid() provides unique but not secure ids and openssl_random_pseudo_bytes() provides secure but not unique ids. Is the combination of the two(following code) a proper approach or…
Stavros
  • 655
  • 7
  • 16
12
votes
8 answers

Gathering entropy in web apps to create (more) secure random numbers

after several days of research and discussion i came up with this method to gather entropy from visitors (u can see the history of my research here) when a user visits i run this…
H M
  • 227
  • 1
  • 6
12
votes
2 answers

Which Pseudo-Random Number Generator to use in C++11?

C++11 comes with a set of PRNG's. In what situation should one choose one over another? What are their advantages, disadvantages etc.
user877329
  • 6,717
  • 8
  • 46
  • 88
11
votes
1 answer

Why are two random deviates needed to ensure uniform sampling of large integers with sample()?

Given that the following are equivalent we might infer that R uses the same C runif function to generate uniform samples for sample() and runif()... set.seed(1) sample(1000,10,replace=TRUE) #[1] 27 38 58 91 21 90 95 67 63 7 set.seed(1) ceiling(…
Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
1
2 3
15 16