Skip to main content

Questions tagged [random]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
163 views

Random Numbers and Collisions [closed]

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 ...
user679560's user avatar
3 votes
4 answers
2k views

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....
Cole Tobin's user avatar
  • 1,496
0 votes
2 answers
807 views

What are the reasons not to use random values in unittests? [duplicate]

I've read the questions regarding the use of random values in unit-tests and, well, I still don't quite understand what the argument against random values is. I'm trying to understand because I've had ...
Byebye's user avatar
  • 337
0 votes
0 answers
295 views

Improving performance of 'Weighted/prioritized left shuffle algorithm'

I wrote a prioritized/weighted left shuffle algorithm (the code is copied from my open source C# project Fluent Random Picker). What does that mean? You've got some values and each of them has a ...
hardfork's user avatar
  • 101
3 votes
3 answers
830 views

How does cuRAND use a GPU to accelerate random number generation? Don't those require a state?

My understanding is that every PRNG or QRNG requires a state to prevent the next item in its sequence from being too predictable; which is sensible, as they're all running on deterministic hardware. ...
Michael Macha's user avatar
-1 votes
2 answers
227 views

How random is enough to be random? [closed]

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 ...
matousc's user avatar
  • 115
-4 votes
1 answer
80 views

How to write a sporadic metronome?

I already asked this question on stackoverflow -- I am posting it here as well, because I think many of you will have encountered an analogous problem. I would appreciate even a link as a reference, ...
 Konstantin Ashkenazy's user avatar
1 vote
4 answers
1k views

Is using multiple UUIDs decrease chance of collisions exponentially?

For example if you have a single UUID with a collision probability of x, if you concatenate 2 UUIDs, does the collision probability become x^2? val0 = generate_uuid() val1 = generate_uuid() final_val ...
Joan Venge's user avatar
  • 1,970
0 votes
3 answers
904 views

How to guarantee an ID is unique in a non-UUID set of values?

I would like to have IDs of different sizes from the alphabet 0-9. So I have 5-length IDs as in 10000 or 13531, etc.. I have 10, 15, 20, up to 39 digit strings (the size of a UUID). I would like to ...
Lance's user avatar
  • 2,615
2 votes
3 answers
824 views

Algorithm for random weighted boolean shuffles?

I don't exactly know how to phrase the thing I'm searching for in a succinct way, which also made it hard to research. In my application I need a random list of booleans, say of length five. The ...
kangalio's user avatar
  • 139
3 votes
3 answers
553 views

Is it really more difficult to debug randomized algorithms?

I am a theoretical computer scientist. I have heard the following: Practitioners do not like randomized algorithms because they are notoriously difficult to debug. So deterministic algorithms are ...
eig's user avatar
  • 147
0 votes
2 answers
116 views

Is it possible to transfer data with a really unique seed of a psudo random number generator

I have thinking about this idea for over 5 years and i don't have the complete technical knowledge to fully grasp the idea I'm having. The premise of the idea is to have an extremely high base number ...
Necro's user avatar
  • 105
0 votes
3 answers
369 views

Getting random yet consistent data for testing

I have a big codebase yet to be covered with tests and rather limited access to the real data. The code that needs to be covered is very data dependent. And the data is anything but shallow and ...
Trident D'Gao's user avatar
1 vote
2 answers
1k views

How to shuffle a large data set without touching every row?

Let’s say I have two larges arrays of users with equals number of rows and I want to match them randomly and one to one(one from the first array,one from the second), I will first need to shuffle one ...
Mathias's user avatar
  • 121
-1 votes
1 answer
331 views

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 ...
Jim's user avatar
  • 21
2 votes
4 answers
591 views

Unit testing Markov chain code

What are the best ways to unit test code that outputs random sequences satisfying specific conditions, such as Markov chains? Let's be specific. There are two natural things to test: That the ...
Legendre17's user avatar
4 votes
2 answers
3k views

Shuffle in music players

I always hear how it is hard to implement shuffle algorithms for music players, but never really the explanation for it. What makes it hard? Take for example how I would implement one: First the ...
Juha Untinen's user avatar
-1 votes
1 answer
2k views

Generating billions of Unique random number [closed]

I recently attended an interview. In that I had to solve the issue for generating an billions of random unique number. For example method signature is as below : public Iterator<Long> ...
MrA's user avatar
  • 111
2 votes
3 answers
317 views

Are all pseudo randomly generated numbers within a given period unique?

This will of course depend on the algorithm generating the pseudo random numbers, but what I'm wondering is whether practical, usable pseudo-random number generating algorithms exist that never repeat ...
Peter Berg's user avatar
2 votes
3 answers
889 views

Can functional programming used for solving problems which require randomness?

This older question tells us that in functional programming "true" randomness cannot be achieved since in FP functions are pure/idempotent and return the same value irrespective of number of ...
Vicky's user avatar
  • 399
0 votes
1 answer
225 views

How to test this getRandom() method? [duplicate]

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 ...
rocky's user avatar
  • 21
7 votes
4 answers
35k views

Testing a function that uses random number generator

I have a method which is a part of the interface I am implementing. This method calls another private method which uses a random number generator to produce output and returns it to the calling method....
sayeed910's user avatar
  • 189
0 votes
1 answer
366 views

Find Randomized Sequence Seed To Compress files statistically

I was wondering if what I have in mind already exists in any known compression programs/algorithms or not. We know that Seed gives us constant sequence of random numbers. so if we be able to find seed ...
M.kazem Akhgary's user avatar
2 votes
2 answers
800 views

Test Driven Development for Stochastic algorithms?

this is similar, but no the same as this post, which was the closest question I could find on this. I don't even see that answer as satisfactory for the question asked in that thread let alone TDD. ...
Krupip's user avatar
  • 1,300
1 vote
2 answers
102 views

Disk file structure for large string list with fast reads by index

I have large list of strings. Each string is of different length, just like sentence in text. Average length is below 255 chars. Please, propose file structure on disk to enable fast picking of random ...
Dmitry Teslenko's user avatar
1 vote
3 answers
220 views

Randomly sorting a list where some states are illegal?

I want to make a randomizer for the items in the game La-Mulana. However, some arrangements of items would mean that the game cannot be completed. Sometimes there's only one group of items required to ...
Smurfton's user avatar
  • 119
5 votes
4 answers
829 views

How to generate a random bag of positive integers that sum up to an input number?

A number N and a range a to b will be input by the user, with a < b < N. The program purpose is to generate random sets of positive integers that sum up to N, with each positive integers within ...
cytsunny's user avatar
  • 637
0 votes
1 answer
829 views

Flowchart: get values from functions. Rectangle or Paralellogram

I need to create a flowchart for one of my algorithms and one step is calling a function (that I don't wish to explain in the flowchart) and assigning the returned value to a variable. float x = ...
Vince Varga's user avatar
5 votes
2 answers
293 views

Is a random sample from a range of uniformly distributed values still uniformly distributed?

Let's say I have a random number generator from which I am requesting values for event A and event B. Both events occur at random intervals but event A happens much more often than event B and I would ...
gregopet's user avatar
  • 213
2 votes
3 answers
1k views

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 ...
Magic Marbles's user avatar
0 votes
1 answer
130 views

Return random item by its weight, advanced level

There are many typical questions like Return random `list` item by its `weight` Imagine more advanced problem. You have N sources of pair (item_id, weight) information. Let's call them Shards. ...
vladon's user avatar
  • 101
4 votes
2 answers
4k views

Generate a unique random 4 digit number from another 4 digit number

I have a database that has two columns. The first column is an index, the second is the path to a data file. There are two types of data files, X and Y. These data files are then processed and graphs ...
Tom's user avatar
  • 151
-1 votes
1 answer
111 views

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) ...
Mike's user avatar
  • 109
2 votes
2 answers
235 views

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 &...
user avatar
-3 votes
1 answer
114 views

What does set.seed(any number) command means? [duplicate]

I am currently studying R. While studying that I came across a command set.seed(any number) . After googling also I didn't understood much except that it has something to do with Random number ...
Dark_Knight's user avatar
4 votes
3 answers
171 views

Restricted randomization of a binary vector

Suppose I have a binary vector of sample size N with each of the two possible values (e.g., 0 and 1 occurring equally often). For example, if N=10, the binary vector is: 0 0 0 0 0 1 1 1 1 1 Suppose ...
Bart's user avatar
  • 51
8 votes
1 answer
2k views

Exclusive upper bound in random number range

Why do languages' random number generators tend to return a value exclusive of the upper bound of the range? For example, an implicit range - JavaScript's random() method "Return a random number ...
John K's user avatar
  • 1,406
1 vote
2 answers
120 views

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

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 ...
user avatar
2 votes
1 answer
105 views

Mechanisms to ensure distributed systems do not sychchronize (anti-synchronize)

We have a service that based on a local timer does a GET request to our server on Azure to transmit some information to be saved on the server. At this stage we are only testing and we are finding ...
miltonb's user avatar
  • 123
0 votes
0 answers
47 views

Pseudorandom in Android

I am building a security mechanism and I need a Pseudorandom functionality in my app. More particularly I need to convert a String to fix length. My strings are random already, they just to long so I ...
Ilya Gazman's user avatar
0 votes
2 answers
474 views

What is a readable algorithm for selecting a random buyer based on what they purchased?

I am working on a giveaway algorithm to select a customer based on what they purchased: If they purchase item 1, they gain 1 point. If they purchase item 2, they gain 2 points. If they purchase item ...
Parham Doustdar's user avatar
6 votes
2 answers
6k views

Why do we need a seed in Random Number Generators?

I want to know how Random number generator(RNG) works in any PL(Programming language). I know the random methods has short periods. i.e they start repeating the values after specific number of time. ...
Jasmeet's user avatar
  • 187
2 votes
1 answer
2k views

Inclusive or exclusive upper bound in pseudo-random number generators

I am creating a little randomization library. One of the methods is similar to .NET's System.Random.Next(int start, int end). The thing is, I am not sure how to decide on whether the upperp bound ...
Kornelije Petak's user avatar
2 votes
2 answers
579 views

Shuffle/Randomize a collection without knowing the number of items? [closed]

Let's say I have a sequence of items of unknown length, n. I want to randomize the order of this sequence without having to go through the entire sequence. Are there any algorithms that can do this? ...
myermian's user avatar
  • 191
9 votes
4 answers
11k views

rand() gives same numbers again for a small range

I'm trying to make sort of a game where I have a a grid of 20x20 and I display a player (P), a target (T) and three enemies (X). All these have an X and a Y coordinate which are assigned using rand(). ...
Rabeez Riaz's user avatar
4 votes
3 answers
785 views

How to pick a random move/action/element non-probabilistically?

I am trying to create a simple AI that can play Go using Monte Carlo Tree Search. This question, however, is valid for all games where players take turns doing some action that, on average, reduce ...
Qqwy's user avatar
  • 4,817
3 votes
3 answers
6k views

Big O notation of randomness

I was thinking about inefficient algorithms based on randomness and wondered how to categorise them. For instance. Say you wanted to generate all the numbers from 1 to N in a random order but only ...
Fogmeister's user avatar
1 vote
3 answers
357 views

Generate random numbers with certain spikes? [duplicate]

I am trying to generate random numbers to simulate steering wheel angles and velocities of a car. So for steering wheels the random numbers could go like 1,2,4,6,4,3,40,0. I can generate random ...
zzzzz's user avatar
  • 227
3 votes
1 answer
597 views

Should changes to FNV-1A's input exhibit the avalanche effect?

This is kind of related to Which hashing algorithm is best for uniqueness and speed?. In that question, the excellently written top answer notes, Randomnessification The other subjective ...
Thanatos's user avatar
  • 517
0 votes
1 answer
1k views

Would adding more digits be a way to scale a order generation service? [closed]

I am working on interview questions from Amazon.com Software Development Engineer Intern Interview Questions. One of the interviewees was asked "give a scalable system design of Amazon.com's order ...
committedandroider's user avatar