cauchy(median?, spread?)
number → numberA heavy-tailed draw around median (default 0) with the given spread (default 1). Mostly close in, but far more prone to a wild outlier than gauss — which is the point when you want the occasional lurch.
Chance: drawn once as the program is lowered, or running as a signal.
A heavy-tailed draw around median (default 0) with the given spread (default 1). Mostly close in, but far more prone to a wild outlier than gauss — which is the point when you want the occasional lurch.
count elements drawn without replacement, in a random order — choice several times over may repeat itself, and this cannot. Asking for the whole list is scramble; asking for more than it holds is an error.
1 or 0, at odds you choose. coin() is even; coin(0.25) answers 1 one time in four. Multiply by it to drop a note, or add it to a velocity.
An exponentially distributed number above zero with the given mean (default 1). Short values are common and long ones rare — the shape of a wait between events.
A normally distributed number: clustered around mean, two thirds of it within one deviation. Both default to the standard 0 and 1. Unbounded — clamp it if a stray value would hurt.
Nudge a number off its grid: x plus a normal draw of deviation amount, so most nudges are small and a few are not. 0.5.humanize(0.05) is a velocity that no longer sounds typed in.
A power-law draw at or above scale (default 1). A smaller shape (default 1) makes big values likelier. Everything is near the floor, with rare excursions far above it.
A whole count averaging mean (default 1) — how many things happened, when each was independent. Good for deciding how many hits land in a bar.
A uniform number. rand() draws from 0..1; rand(lo, hi) — or 60.rand(72) — draws from lo..hi, with hi excluded.
A uniform whole number in lo..hi, with hi excluded: randi(60, 72) is an octave of notes that never repeats the root. Both bounds must be whole.
A list of count whole numbers in lo..hi, hi excluded: randis(8, 60, 72) >> play(lead) is an eight-note riff.
A list of count uniform numbers, from 0..1 or from lo..hi. A pattern in one line: rands(8, 0.2, 0.9) is eight velocities.
count notes drawn evenly from the tones of a scale, given as semitone offsets within an octave, between MIDI lo and hi (60..72 by default). Unlike snapping a uniform draw with scale, every degree is equally likely and nothing lands outside the range: randscale(8, [0, 3, 5, 7, 10], 48, 72) is a pentatonic riff over two octaves.
Fix every draw made after it, and answer with the seed. seed(42) at the top of a program makes its lists, lanes and patterns come out the same on every evaluation — which is how a happy accident gets kept. A voice is lowered per note and does not see a top-level seed, so a seed inside an instrument pins that instrument instead, identically on every note.
A triangular draw over lo..hi, peaking at mode — the midpoint if you leave it out. Bounded like rand but with a centre, so it favours a value without ever leaving the range.
A random walk: count numbers beginning at start, each drifting from the one before by up to step either way. Neighbours stay close, so it moves rather than jumps — what rands is not. Good for a cutoff or a pan.
walk in whole steps: each move is a whole number from -step to step, so the result stays on the semitone grid. walki(16, 60, 2) wanders a melody around middle C. step must be whole.
17names in Random. All categories.