Questions tagged [random]

This tag is for questions dealing with random numbers, pseudorandom numbers, and computer entropy.

In computing a "random" number is used for a variety of purposes including:

  • Generating cryptography keys such that two pieces of data are highly unlikely to be encrypted with the same key.

  • Allowing AI some measure of unpredictability: an enemy character in a game, for example, might react slightly differently on two different playthroughs, making the game more difficult.

Most computers are really good at generating pseudorandom numbers: these are numbers that typically start from a seed value, and generate a sequence of numbers that repeats after many values are generated. One may "reseed" the pseudorandom number generator to generate the same sequence again.

Another way of generating randomness is through entropy: a source of data outside of the computer's core CPU and memory is used to generate a sequence of bits. Perhaps tiny fluctuations in the case temperature, variations in the input voltage of the power supply, or some other source of data could be used to generate bits that are more unpredictable than a pseudorandom number generator (but may still have bias).

Questions in this tag will deal with how to generate or use random numbers in computing.

124 questions
11
votes
4 answers

Can a random number generator ever produce different output given identical seeds?

The title sums it up. I'm interested to know if there exists an algorithm capable of producing variable output given identical input without relying on other sources for randomness such as DateTime.Now or a number generated from a light sensor etc.…
4
votes
5 answers

How to create a random generator

How could a random generator be implemented? I'm not speaking about the invocation of a language mathRandom() method, but the implementation of the routines that lead to generate numbers totally random.
Asgard
  • 287
  • 1
  • 9
2
votes
3 answers

Is checking if a new GUID exists before insert a code smell?

Say I use GUIDs as keys. Considering the chance of a duplicate GUID being generated being what they are, is code like this considered a code smell? Guid newID = GenerateGuid(); while (dictionary.HasKey(newID)) newID =…
Cole Tobin
  • 1,469
2
votes
3 answers

Programming a Truly "Fair" Weighted Random Dice Roll

I'm trying to devise a way to create a 'loot table' for an RPG, mostly to see if it can be done. I'm partly inspired by old D&D style tables, which would list a range of values for each item on the table (i.e. 0-20 weather is clear, 21-50 weather is…
2
votes
2 answers

Identifying and understanding this PRNG

I have this random number generator, and have had it for quite some time, but despite how much I use it I don't really understand it. public static int Random(int x) { x = x + seed; x = (x << 13) ^ x; return (x * (x * x * 15731 + 789221)…
user234599
2
votes
1 answer

Generating a Nakagami Random Variable

Assuming the only tool for generating random numbers I have available is generating a uniformly distributed variable u on U(0,1). I want to generate a Nakagami Random Variable from it. I know I could just plug u into the inverse CDF of the Nakagami…
2
votes
1 answer

How does minecraft use a seed to generate a completely unique world?

In minecraft, before creating a world you have an option to input a seed. The algorithm takes the seed and creates a completely unique world. How does this work?
1
vote
1 answer

Random Numbers and Collisions

I read a question about using a 32bit random number as a "unique" identifier. One of the answers asserted that a "rough guide" to estimating collision likelihood is that there's a 50% chance of a collision once about sqrt(n) numbers have been…
1
vote
2 answers

If the size of a set exceeds the period of a PRNG, is it true that some combinations may be unable to be generated?

Given that the size of some sets (example, 52! (about 2226 or 8*1067), the number of ways to shuffle a regular deck of cards) exceeds the period of most Pseudorandom Number Generators (PRNG), is it true that some combinations may be unable to be…
user170146
0
votes
1 answer

How to test this getRandom() method?

There are strings and each string has a weight in a data structure. The getRandom() method should return a string randomly with its weight/total weight probability. There is already a question on how to define this getRandom() method on…
rocky
  • 21
-1
votes
2 answers

How random is enough to be random?

I download the atmospheric noise data from random.org in form: 10111011 01101111 01100001 00001001 00100110 10111011 01110110 11010110 00000111 01111110 10001110 01101010 11100000 11110111 10101011 01001011 11010111 00100110 01001011 11101111…
matousc
  • 115
-1
votes
1 answer

Choosing random cards from a deck?

Is there a difference between the 2 below methods for choosing a random card from a deck of cards? Is one approach more accepted than the other? Method 1: Generate a random number from 1-52 for the first card them remove that card from the array…
Jim
  • 21
-1
votes
1 answer

How would you explain or visually show someone the difference between linear/static probability vs dynamic?

Forgive me if I'm using the wrong terminology, but I'm attempting to explain to a non-technical person the difference between something happening in a program due to either a Math.Random (seed PRNG) and something happening every nth time. So,…
Mike
  • 109