home/ atoms/ custom-probability-distribution

Raising a uniform random value to a power skews its distribution toward one end of its range

Processing’s random(1) returns a flat uniform distribution between 0 and 1. Applying pow(random(1), n) skews the distribution: exponents greater than 1 concentrate values near 0 (most points will be small); the expression 1 - pow(random(1), 5) inverts this, concentrating values near 1. This is a lightweight technique for custom probability distributions without libraries — a visual ‘gravity’ toward one end of a range. The effect is distinct from noise: it produces independent samples rather than smooth sequences. It is the random-sample analogue of shaping a smooth counter with a custom function.

Examples

ch3_3_3_CustomRandom.pde defines float customRandom(){ float retValue = 1 - pow(random(1),5); return retValue; } — most values will be near 1.0; this drives the y-offset of a wandering line.

Assessment

Plot (on paper) the approximate output distribution of pow(random(1), 5) versus 1 - pow(random(1), 5). Then explain what visual characteristic this gives to a line drawn with customRandom() as its y-offset.

“float customRandom(){ float retValue = 1 - pow(random(1),5); return retValue; }”
corpus · generative-art-code-examples-josephfiola-genart-processing-p · chunk 30