How do I add a random offset to values in a Pseq?

253 Views Asked by At

Given a Pseq similar to the following:

Pseq([1, 2, 3, 4, 5, 6, 7, 8], inf)

How would I randomise the values slightly each time? That is, not just randomly alter the 8 values once at initialisation time, but have a random offset added each time a value is sent to the stream?

1

There are 1 best solutions below

2
On BEST ANSWER

Here's a neat way:

(Pseq([1, 2, 3, 4, 5, 6, 7, 8], inf) + Pgauss(0, 0.1))

First you need to know that Pgauss is just a pattern that generates gaussian random numbers. You can use any other kind of pattern such as Pwhite.

Then you need to know the really pleasant bit: performing basic math operations on Patterns (as above) composes the patterns (by wrapping them in Pbinop).