Sunday, March 8, 2026

Code Math: Sine as pseudo 1D noise generator

Lets use sine as a randomness provider to generate a infinite sequence of random numbers that change smoothly with no state:

1. Step wave that grows from 0-1 and resets back to 0 again every 1:

step(x) = ((x % 1) + 1) % 1

2-3. The random number generator from the last post:

random(x) = sin(floor(x) ** 3)

4. Interpolate between the current random number and the next:

noise(x) = step(x) * random(x + 1) + (1 - step(x)) * random(x)

5. Combine multiple sequences of different frequencies and amplitudes:

noise(x) + noise(x * 2) / 2 + noise(x * 4) / 4 + noise(x * 8 ) / 8

Graph of each:



done_