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

Correct OpenMP pragmas for pi monte carlo in C with not thread-safe random number generator

I need some help to parallelize the pi calculation with the monte carlo method with openmp by a given random number generator, which is not thread safe. First: This SO thread didn't help me. My own try is the following #pragma omp statements. I…
Danny Archer
  • 215
  • 4
  • 12
2
votes
2 answers

Deterministic pseudorandom number generation in R

I need to generate a vector of "random" numbers, except that they need to be fully deterministic. The distribution from which the numbers come is not so important. What is a simple way to do this in R? The reason for not using something like runif…
Museful
  • 6,711
  • 5
  • 42
  • 68
2
votes
0 answers

What is a good relation between seeds given to srand48_r

In a multithreaded program where each thread has its own state of the rand48 PRNG, what is a good relation between the seeds. Obviously, I cannot use the same seed since then they generate the same sequences. How uncorrelated will they be for seeds…
user877329
  • 6,717
  • 8
  • 46
  • 88
2
votes
2 answers

PRNG seeded by key in java

I need to create numbers pseudo randomly using a key. key is a string converted to byte array. This is what i came up with: int N=10; int key[]= {13,10,1,5}; int tmp,j=0; for (int i=0; i < N; i++) { j = (j + key[i %…
Amar C
  • 374
  • 5
  • 17
2
votes
3 answers

Simple PRNG algorithm has different Python/C output - integer overflow differences?

Edit: As it turns out, I typoed the seed value in my test code in the C version (It wasn't the same as I pasted in this question), so I was getting different output. Thanks everyone. I need to generate psuedo random numbers in a C program, and then…
Salis
  • 433
  • 1
  • 8
  • 15
2
votes
3 answers

How to generate random directions (N, S, E, W, none) with some kind of "momentum"?

I'm trying to perform explore a grid in a random fashion. The five possible directions I can go are north, east, south, west, and stay, all of which are equally likely, at least initially. The trouble with simply choosing a random direction from the…
user541686
  • 205,094
  • 128
  • 528
  • 886
2
votes
5 answers

How to generate a seed from an xy coordinate

Iv'e been working on a perlin script but have been having problems with creating simple pseudo random values. I need to be able to create a seed value from an xy coordinate but x+y has obvious problems with recurring values. Also they go into…
josh247
  • 155
  • 1
  • 13
2
votes
3 answers

Random with certain seed still seems random

I've got a program which makes heavy use of random numbers to decide what it needs to be doing, and has many many execution paths based on the output of the PRNG. After pulling my hair out trying to debug it, I decided to make all PRNG calls…
Lynden Shields
  • 1,062
  • 1
  • 10
  • 27
2
votes
4 answers

Truly random number generator

From what I understand PRNG uses a seed that generates a sequence of numbers that is not truly random. Would it be possible to create a truly random number generator by reusing PRNG over and over with different seeds each time it is used. The seed…
user990246
1
vote
2 answers

Trying to write an invertible PRNG of 8 bits, not a cipher

I'm trying to build a PRNG of bytes where I can take a set of bytes (say, 10 or 15 bytes) and return a list of seeds that would yield that list of bytes. I'm not concerned about cryptography, but it must be roughly uniformly distributed, it must hit…
digdig
  • 230
  • 3
  • 8
1
vote
2 answers

Why is SecureRandom in Java called CS PRNG and not TRNG?

SecureRandom internally makes use of other algorithms , like in case of Linux , makes use of NativePRNG which in turn makes use of /dev/urandom . But /dev/urandom is actually using interrupts events etc to generate entropy which is similar to a True…
Pargarg
  • 33
  • 5
1
vote
1 answer

Codes for scratch cards

I'll try to be simple, clear and direct. My problem is the following: I have a project where I need to generate codes for scratch cards. The scrath cards are printed like the ones you use for charging your mobile phone. The system is that people…
RedLion
  • 11
  • 1
  • 2
1
vote
1 answer

How to generate a list of shuffled integers between 2 numbers?

I want to create a shuffled set of integers such that: Given the same seed, the shuffle will be the same every time As I iterate through, every number in the shuffled set will be used exactly once before repeating itself Will work for large sets (I…
esac
  • 24,099
  • 38
  • 122
  • 179
1
vote
3 answers

A safe random number, such as an integer from /dev/random, for Windows platform?

In my application, I require a function to generate (unpredictably) random values that differ each time when called such as inside a fast loop. On Linux platforms which is the platform I will release my script (of which shall be run under SSL in…
Alexander
  • 1,053
  • 11
  • 16
1
vote
4 answers

How to generate a random number based on a byte array?

Suppose I have an array of bytes from a secure PRNG, and I need to generate a number between 1 and 10 using that data, how would I do that correctly?
Maestro
  • 9,046
  • 15
  • 83
  • 116