Linked Questions

16 questions linked to/from Weighted random selection from array
0 votes
2 answers
5k views

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 ...
btt's user avatar
  • 141
4 votes
0 answers
162 views

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. ...
ahwulf's user avatar
  • 2,584
0 votes
1 answer
134 views

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

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 ...
Riples's user avatar
  • 1,167
81 votes
14 answers
42k views

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

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

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

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 ...
roflwaffle's user avatar
  • 30.8k
1 vote
2 answers
799 views

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

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

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 ...
Forrest's user avatar
  • 151
0 votes
1 answer
958 views

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

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 ...
charlesD's user avatar
1 vote
1 answer
977 views

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

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?
Semih Gür's user avatar

15 30 50 per page
1
2