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
3
votes
1 answer

How to use contract-out in Racket

I have written a complimentary-multiply-with-carry PRNG in Racket. I want to use provide to restrict access only to certain functions within my library, and to impose contracts on them. Using the Racket Documentation (linked above), I have put the…
djhaskin987
  • 9,741
  • 4
  • 50
  • 86
3
votes
3 answers

Put in a string the output of autoseed PNRG in Crypto++

I'm using Cryptopp to generate a random string. This is the code: const unsigned int BLOCKSIZE = 16 * 8; byte pcbScratch[ BLOCKSIZE ]; // Construction // Using a ANSI approved Cipher CryptoPP::AutoSeededX917RNG
user840718
3
votes
8 answers

What is a possible way to bias a random number generator?

I built a word generator, it picks a length and then randomly picks letters of the alphabet to make up words. The program works but 99% of the output is rubbish as it is not observing the constructs of the English language, I am getting as many…
Skeith
  • 2,512
  • 5
  • 35
  • 57
3
votes
3 answers

What is a good hashing algorithm for seeding a prng with a string?

I am looking for a hashing algorithm that produces a 31/32 bit signed/unsigned integer as a digest for a utf8 string with the purpose of using the output for seeding a prng, such as a Park-Miller-Carta LCG or a Mersenne-Twister. I have looked into…
Hristo
  • 740
  • 2
  • 7
  • 19
3
votes
4 answers

Java Random seed

I need to test out a Java program 20 times and need to set the random seed so that the tests can be repeated. If I were to set the initial seed as 0 and then increment by 1 at each run (i.e. 1,2,3 etc), would this method still ensure complete…
badcoder
  • 3,624
  • 5
  • 32
  • 33
3
votes
3 answers

Generate a random number which is greater than a specific number

In Advanced Bash-Scripting Guide Chaper 9.3. $RANDOM: generate random integer It illustrates how to generate a random number greater than a specific number: FLOOR=200 number=0 #initialize while [ "$number" -le $FLOOR ] do …
Vayn
  • 2,507
  • 4
  • 27
  • 33
3
votes
1 answer

Using engines for random number generation

I am trying to use the RAND_bytes API of OpenSSL, but I want to try it with various Random Number Generating Engines. Is there a recommended way of generating Random bytes and adding entropy in OpenSSL? Where can I get other Engine implementations,…
SkypeMeSM
  • 3,197
  • 8
  • 43
  • 61
3
votes
0 answers

Javascript implement PRNG

I'm trying to write a small multiplayer game, running as part of a website, utilizing websockets for communication. Therefore client needs to be javascript, however server is golang. The idea is to synchronize only by sending player inputs, meaning…
user2089648
  • 1,356
  • 2
  • 17
  • 31
3
votes
1 answer

Maple: RNG is not random

i was "finding Pi" with Monte Carlo Method, but the answer was incorrect. The oryginal code was: RandomTools[MersenneTwister]: with(Statistics): tries := 10000: s := 0; for i to tries do if GenerateFloat()^2+GenerateFloat()^2 < 1 then s :=…
Z-DNA
  • 133
  • 1
  • 10
3
votes
3 answers

Stable mapping of an integer to a random number

I need a stable and fast one way mapping function of an integer to a random number. By "stable" I mean that the same integer should always map to the same random number. And by "random number" I actually mean "some number which behaves like…
Scheintod
  • 7,953
  • 9
  • 42
  • 61
3
votes
3 answers

How can C/C++'s rand() generate random numbers so quickly?

My understanding is that a pseudo-random number generator basically just takes some number (the seed), hashes it with a bunch of XORs and bitshifts, and then spits out a really long number from which a remainder can be retrieved to get your "random"…
Coffee Maker
  • 1,543
  • 1
  • 16
  • 29
3
votes
1 answer

Something like a reversed random number generator

I really don't know what the name of this problem is, but it's something like lossy compression, and I have a bad English, but I will try to describe it as much as I can. Suppose I have list of unsorted unique numbers from unknown source, the…
user1748906
  • 526
  • 4
  • 13
3
votes
1 answer

What is the advantage of using mt19937_64 over its 32 bit variant?

I have been wondering what would be the advantage of using mt19937_64 (for instance in boost, or c++11) over its 32 bit variant? Thanks.
user119690
  • 31
  • 2
3
votes
1 answer

Characteristics of the Mersenne Twister - 19937

I have a quite simple question: When we take the Mersenne Twister -19937 generator and we fix the seed, then everytime we call the generator it produces a sequence of numbers that have some characteristics (independence, uniform distribution).…
VLT
  • 197
  • 1
  • 11
3
votes
0 answers

Is it secure to seed PRNGs with the sequences from CSPRNG?

java.security.SecureRandom besides others has two methods: generateSeed(int numBytes) and nextBytes(byte[] bytes). The former gets entropy from the external source and is less predictable but slower, the latter uses PRNG sequence and is more…
shpikachu
  • 147
  • 1
  • 3
  • 12