# Tag Info

## Hot answers tagged random

### Be big more often

Python, 41 bytes lambda l:choices(l,l) from random import* Attempt This Online! or run it 100000 times Uses the list itself as the weights.
• 761

### Be big more often

R, 27 bytes (Or 20 bytes in R>=4.1 using \ instead of function) ...
• 33.6k

### Be big more often

Python, 64 bytes (also supports negative numbers) lambda l:sorted(l)[int(len(l)*random()**.5)] from random import* Attempt This Online! Explanation Sort the list, ...
• 4,653

### Be big more often

J, 8 bytes #~{~1?+/ Attempt This Online! 1?+/ Sum the numbers and then choose a random index between 0 and the sum ...
• 32.4k

### Be big more often

Vyxal, 4 bytes ℅?℅∴ Try it Online! Return the highest of two random picks ...
• 33.6k

### Be big more often

JavaScript (Node.js), 41 bytes a=>a.sort()[a.length*Math.random()**.5|0] Try it online! or run it 100000 times Takes an ...
• 761

### Be big more often

WolframLanguage, 63 48 bytes Thanks to att for shaving of 15 Sort[#][[Floor@Log2[Random[](2^Tr[1^#]2-3)+2]]]& Original answer: ...
• 1,637

### Be big more often

Ruby, 32 24 bytes ->l{(l+l).sample(2).max} Try it online! Thanks to Dominic van Essen for -4 bytes and the idea to get to -8.
• 20.8k

### Be big more often

JavaScript (Node.js), 58 bytes a=>a.sort((a,b)=>b-a).filter(_=>Math.random()<.5)[0]||a[0] Try it online! Sorts the numbers, filters them randomly, ...
• 639

### Be big more often

Charcoal, 10 bytes ＦＡＦι⊞υιＩ‽υ Try it online! Link is to verbose version of code. Explanation: ＦＡ Loop over the input numbers. <...
• 163k

### Be big more often

Wolfram Language (Mathematica), 19 bytes RandomChoice[#->#]& Try it online! Like other languages, the builtin can use weights, so the input can serve as the ...
• 15.4k

### Be big more often

Jelly, 3 bytes X»X Attempt This Online! Distribution over 1000 runs: Attempt This Online! Uses Dominic van Essen's insight: pick a random element (...
• 23.2k

### Be big more often

Raku, 13 bytes *.roll(2).max Attempt This Online! Picks two elements independently and returns the max of the two.
• 47k

### Be big more often

Julia, 37 bytes !l=rand([fill.(sort(l),keys(l))...;]) Attempt This Online! sort the list and repeat each element by their index before randomly choosing a number ...
• 6,155

### Be big more often

Factor, 35 bytes [ [ dup <array> ] map-flat random ] Attempt This Online! Create n copies of each n, and select one at random (uniformly). For instance, <...
• 20.8k

### Be big more often

Jelly, 4 bytes ṢxJX A monadic Link that accepts a list of distinct floats and outputs a random one. Try it online! Or see the results of 10,000 runs. How? Weights ...
• 102k
1 vote

### Be big more often

Vyxal, 3 bytes øḊ℅ Try it Online! Explained ...
• 31.4k
1 vote

### Make your code error, but only sometimes!

Volatile, 3 bytes ~~/ ~ pushes a random number onto the stack (which may include zero), and ...
• 771
1 vote

### Randomize the scalars of an array

Arturo, 17 bytes \$=>[shuffle@0..&] Try it! ...
• 20.8k
1 vote

### Randomize the scalars of an array

Factor, 25 bytes [ dup [0,b] swap sample ] Try it online! ...
• 20.8k
1 vote

### Randomize the scalars of an array

Thunno 2, 3 bytes Ėµr Try it online! Explanation ...
• 17.5k

Only top scored, non community-wiki answers of a minimum length are eligible