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
11
votes
2 answers

Is PHP's rand function really so bad?

I know that it is encouraged to use mt_rand() over rand() because it uses the Mersenne Twister over whatever PRNG rand() uses, but here's something that never seems to be factored in: user activity. In fact, the actions of users can be considered…
Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
10
votes
6 answers

Computing (a*b) mod c quickly for c=2^N +-1

In 32 bit integer math, basic math operations of add and multiply are computed implicitly mod 2^32, meaning your results will be the lowest order bits of the add or multiply. If you want to compute the result with a different modulus, you certainly…
SPWorley
  • 11,550
  • 9
  • 43
  • 63
10
votes
2 answers

How (if at all) does a predictable random number generator get more secure after SHA-1ing its output?

This article states that Despite the fact that the Mersenne Twister is an extremely good pseudo-random number generator, it is not cryptographically secure by itself for a very simple reason. It is possible to determine all future states of the…
emboss
  • 38,880
  • 7
  • 101
  • 108
10
votes
5 answers

Pseudo-random number generator for cluster environment

How can I generate independent pseudo-random numbers on a cluster, for Monte Carlo simulation for example? I can have many compute nodes (e.g. 100), and I need to generate millions of numbers on each node. I need a warranty that a PRN sequence on…
Charles Brunet
  • 21,797
  • 24
  • 83
  • 124
10
votes
5 answers

How to generate Bad Random Numbers

I'm sure the opposite has been asked many times but I couldn't find any answers on how to generate bad random numbers. I want to write a small program for cluster analysis and want to generate some random Points for testing. If I would just insert…
Nicolas
  • 1,828
  • 6
  • 23
  • 34
9
votes
4 answers

What (else) is wrong with using time as a seed for random number generation?

I understand that time is an insecure seed for random number generation because it effectively reduces the size of the seed space. But say I don't care about security. For example, say I'm doing a Monte Carlo simulation for a card game. I DO…
pepsi
  • 6,785
  • 6
  • 42
  • 74
9
votes
2 answers

R doesn't reset the seed when "L'Ecuyer-CMRG" RNG is used?

I was doing some parallel simulations in R and I notice that the seed is not changed when the "L'Ecuyer-CMRG" rng is used. I was reading the book "Parallel R", and the option mc.set.seed = TRUE should give each worker a new seed each time mclapply()…
Matteo Fasiolo
  • 541
  • 6
  • 17
9
votes
3 answers

Using SecureRandom with SHA-256

I have been using SecureRandom with a seeded SHA1PRNG algorithm to create shared randomness between two processes. I recently learned that SHA1 is being deprecated according to NIST's standards, so we are making an effort to switch to SHA256. The…
David K
  • 1,296
  • 18
  • 39
8
votes
2 answers

Quality of PostgreSQL's random() function?

Let's say I'm creating a table foo with a column bar that should be a very large random integer. CREATE TABLE foo ( bar bigint DEFAULT round(((9223372036854775807::bigint)::double precision * random())) NOT NULL, baz text ); Is this the…
Dustin Kirkland
  • 5,323
  • 3
  • 36
  • 34
8
votes
2 answers

C++11 Generating random numbers from frequently changing range

Q: How do I generate (many) uniformly distributed integers from a-priory unknown ranges? What is the prefered way in terms of performance (milions of generated numbers)? Context: In my app I have to generate many pseudo random numbers in many…
teejay
  • 2,353
  • 2
  • 27
  • 36
8
votes
3 answers

Is Ruby's seed for OpenSSL::Random sufficient?

I know very little about Ruby, so please forgive me if the answer to this is obvious. I noticed at http://www.ruby-doc.org/stdlib-1.9.3/libdoc/securerandom/rdoc/SecureRandom.html that Ruby uses the pid and the current time to seed OpenSSL::Random…
iamtheneal
  • 113
  • 1
  • 8
8
votes
1 answer

Simple method call is really slow?

Edit: I've resolved my problem. The cause was an error in testing procedure and will be detailed once I'm allowed to answer my own question. I know this type of question should generally be avoided, but I've come across a really strange situation…
Kira Chow
  • 185
  • 1
  • 7
7
votes
3 answers

An RNG faster than /dev/random but cryptographically useful?

I've started some work of which requires some quality random bytes, such as 32 at a time for an initialising vector for certain cryptographic applications. My issue is, this may be called upon multiple times simultaneously and I cannot afford the…
Alexander
  • 1,053
  • 11
  • 16
7
votes
2 answers

Is there "good" PRNG generating values without hidden state?

I need some good pseudo random number generator that can be computed like a pure function from its previous output without any state hiding. Under "good" I mean: I must be able to parametrize generator in such way that running it for 2^n iterations…
actual
  • 2,370
  • 1
  • 21
  • 32
7
votes
1 answer

Cross-platform cross-language cross-everything actually deterministic random number generator

I'm looking for an algorithm to generate random numbers from a given seed but with the particular requirement that it will always generate the same sequence of number regardless of the underlying computer architecture or language implementation. I…
Ale Morales
  • 2,728
  • 4
  • 29
  • 42
1
2
3
15 16