Linked Questions
16 questions linked to/from Weighted random selection from array
0
votes
2
answers
5k
views
Get random element from array with weighted elements [duplicate]
I have an array of objects that represent creatures in a game I'm trying to develop. These objects have (among others) a unique identifier and a weight (or probability) to spawn.
I'm trying to ...
4
votes
0
answers
162
views
Is there a faster method of doing a random weighted choice for a large list of items [duplicate]
Assume I have a list of items each with a weight and I want to pick a random item. The easiest way to implement this is to keep the list of items and a running sum of the weights sorted by the sum. ...
0
votes
1
answer
134
views
Choosing a function to run based on percentages [duplicate]
I'd like to know how to choose a function to run based on a percentage. For example, function1() might have a 60% chance of running, function2() might have a 30% chance of running and function3() ...
0
votes
0
answers
40
views
What is the best way to generate a random number based on 3 different probabilities [duplicate]
I am after some help trying to get my head around the logic needed to generate a random number based on 3 different probabilities.
My example is this:
I have an array of objects. Upon each cycle, this ...
81
votes
14
answers
42k
views
Select k random elements from a list whose elements have weights
Selecting without any weights (equal probabilities) is beautifully described here.
I was wondering if there is a way to convert this approach to a weighted one.
I am also interested in other ...
151
votes
4
answers
16k
views
Data structures for loaded dice?
Suppose that I have an n-sided loaded die, where each side k has some probability pk of coming up when I roll it. I’m curious if there is a good data structure for storing this information statically (...
54
votes
9
answers
36k
views
Weighted random selection with and without replacement
Recently I needed to do weighted random selection of elements from a list, both with and without replacement. While there are well known and good algorithms for unweighted selection, and some for ...
8
votes
2
answers
5k
views
Picking random element by user defined weights [duplicate]
Possible Duplicate:
Generating random results by weight in PHP?
I have a web application where users can add 1-20 strings of text and assign a weight to them of how often it should show up. The ...
1
vote
2
answers
799
views
Picking objects from a vector with defined probabilities on matlab/octave
Is there any function on Matlab/Octave that randomly picks a value from a list accordingly to a given probability?
For example: we have the vector [1 3 7]. The function I am looking for should pick ...
0
votes
2
answers
778
views
How to implement weighted random selection in Google Sheets based on rarity ranking
I am working on building a tool to help with my DND campaigns that will randomly give me a set number of items from the master list of the game. Needed some help wrapping my head around weighted ...
1
vote
2
answers
474
views
How do I select a random key from a hash using the probability distribution stored within the corresponding values?
When I create a new opal, I want to randomly assign it one of many possible features. However, I want some qualities to be more common than others. I have a hash with possible features and their ...
0
votes
1
answer
958
views
Weighted Random Selection With Dynamic Probabilities
I've been looking for a good algorithm for selecting a random object from a list of objects with differently weighted probabilities, and have found a veritable trove of possibilities, from putting ...
1
vote
1
answer
583
views
How can I randomly weight an element from an array and then pick it based on those weights?
I want to pseudo-randomly pick one element from an array of 5 elements: I want to control the occurrence probability of each of those 5 elements.
Example: I have an array like this: [A B C D E]
I ...
1
vote
1
answer
977
views
Weighted Random Item selection without replacement, drawn multiple times
I'm trying to build a system where I have a list of Items with weights associated with them. I want to randomly pull items from this pool, using their weights to determine chance of selection.
In the ...
-3
votes
1
answer
62
views
How can I assign a value to a random element of 2D array in C
For example, there is an array like this ==> array[10][10]
I want to pick a random element of this array like array[5][7] and assign it to 0.
How can I do it?