Here's an example of a random walk that is biased towards the middle of its range and is guaranteed not exceed its bounds.
Hope someone finds it useful, I'm using it for melodies in a generative piece (I'll publish the full patch in a couple of weeks).
Any statisticians want to analyse it further than I have? Anyone have any suggestions for improvements?
http://claudiusmaximus@goto10.org
#N canvas 0 0 781 423 10; #X obj 21 103 f 5; #X obj 184 111 random 10; #X obj 184 137 moses; #X obj 162 194 +; #X obj 21 130 t f f; #X obj 65 225 max -100; #X obj 65 245 t f f; #X floatatom 65 267 5 0 0 0 - - -; #X obj 43 309 t f f; #X floatatom 43 331 5 0 0 0 - - -; #X floatatom 21 371 5 0 0 0 - - -; #X obj 21 26 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1 1 ; #X obj 162 79 t f b f; #X msg 184 159 -1; #X msg 214 159 1; #X obj 43 288 min 100; #X obj 21 51 metro 100; #X floatatom 79 26 5 0 0 0 - - -; #X obj 21 168 t f f f; #N canvas 0 0 456 412 $0-test-100 0; #X obj 314 172 moses; #X obj 292 229 +; #X obj 151 165 t f f; #X obj 292 114 t f b f; #X msg 314 194 -1; #X msg 344 194 1; #X obj 151 138 f 50; #X obj 314 146 random 99; #X obj 151 223 t f f; #X obj 151 274 + 1; #X obj 151 103 until; #X msg 33 304 normalize 1; #X obj 33 34 t b b b; #X msg 77 280 const 0; #X obj 33 331 s $0-distribution-100; #X obj 151 297 tabwrite $0-distribution-100; #X obj 151 251 tabread $0-distribution-100; #X msg 151 76 100000; #X obj 33 12 inlet; #X connect 0 0 4 0; #X connect 0 1 5 0; #X connect 1 0 6 1; #X connect 2 0 8 0; #X connect 2 1 3 0; #X connect 3 0 1 0; #X connect 3 1 7 0; #X connect 3 2 0 1; #X connect 4 0 1 1; #X connect 5 0 1 1; #X connect 6 0 2 0; #X connect 7 0 0 0; #X connect 8 0 16 0; #X connect 8 1 15 1; #X connect 9 0 15 0; #X connect 10 0 6 0; #X connect 11 0 14 0; #X connect 12 0 11 0; #X connect 12 1 17 0; #X connect 12 2 13 0; #X connect 13 0 14 0; #X connect 16 0 9 0; #X connect 17 0 10 0; #X connect 18 0 12 0; #X restore 476 182 pd $0-test-100; #N canvas 0 0 450 300 (subpatch) 0; #X array $0-distribution-100 100 float 4; #X coords 0 1 99 0 128 100 1; #X restore 474 223 graph; #X obj 476 160 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #N canvas 0 0 450 300 (subpatch) 0; #X array $0-distribution-10 10 float 4; #X coords 0 1 9 0 128 100 1; #X restore 331 223 graph; #X obj 333 161 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #N canvas 0 0 450 300 (subpatch) 0; #X array $0-distribution-1000 1000 float 4; #X coords 0 1 999 0 128 100 1; #X restore 617 223 graph; #X obj 619 160 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #N canvas 0 0 456 412 $0-test-10 0; #X obj 314 172 moses; #X obj 292 229 +; #X obj 151 165 t f f; #X obj 292 114 t f b f; #X msg 314 194 -1; #X msg 344 194 1; #X obj 151 223 t f f; #X obj 151 274 + 1; #X obj 151 103 until; #X msg 33 304 normalize 1; #X obj 33 34 t b b b; #X msg 77 280 const 0; #X msg 151 76 100000; #X obj 33 12 inlet; #X obj 314 145 random 9; #X obj 151 137 f 5; #X obj 151 251 tabread $0-distribution-10; #X obj 151 297 tabwrite $0-distribution-10; #X obj 33 331 s $0-distribution-10; #X connect 0 0 4 0; #X connect 0 1 5 0; #X connect 1 0 15 1; #X connect 2 0 6 0; #X connect 2 1 3 0; #X connect 3 0 1 0; #X connect 3 1 14 0; #X connect 3 2 0 1; #X connect 4 0 1 1; #X connect 5 0 1 1; #X connect 6 0 16 0; #X connect 6 1 17 1; #X connect 7 0 17 0; #X connect 8 0 15 0; #X connect 9 0 18 0; #X connect 10 0 9 0; #X connect 10 1 12 0; #X connect 10 2 11 0; #X connect 11 0 18 0; #X connect 12 0 8 0; #X connect 13 0 10 0; #X connect 14 0 0 0; #X connect 15 0 2 0; #X connect 16 0 7 0; #X restore 333 183 pd $0-test-10; #N canvas 0 0 456 412 $0-test-1000 0; #X obj 314 172 moses; #X obj 292 229 +; #X obj 151 165 t f f; #X obj 292 114 t f b f; #X msg 314 194 -1; #X msg 344 194 1; #X obj 151 223 t f f; #X obj 151 274 + 1; #X obj 151 103 until; #X msg 33 304 normalize 1; #X obj 33 34 t b b b; #X msg 77 280 const 0; #X msg 151 76 100000; #X obj 33 12 inlet; #X obj 151 251 tabread $0-distribution-1000; #X obj 151 297 tabwrite $0-distribution-1000; #X obj 33 331 s $0-distribution-1000; #X obj 314 146 random 999; #X obj 151 138 f 500; #X connect 0 0 4 0; #X connect 0 1 5 0; #X connect 1 0 18 1; #X connect 2 0 6 0; #X connect 2 1 3 0; #X connect 3 0 1 0; #X connect 3 1 17 0; #X connect 3 2 0 1; #X connect 4 0 1 1; #X connect 5 0 1 1; #X connect 6 0 14 0; #X connect 6 1 15 1; #X connect 7 0 15 0; #X connect 8 0 18 0; #X connect 9 0 16 0; #X connect 10 0 9 0; #X connect 10 1 12 0; #X connect 10 2 11 0; #X connect 11 0 16 0; #X connect 12 0 8 0; #X connect 13 0 10 0; #X connect 14 0 7 0; #X connect 17 0 0 0; #X connect 18 0 2 0; #X restore 619 182 pd $0-test-1000; #X text 332 22 self-centering random walk technique; #X text 333 45 probability of decrease decreases as the value decreases ; #X text 333 59 probability of increase decreases as the value increases ; #X text 356 160 N = 10; #X text 498 159 N = 100; #X text 645 159 N = 1000; #X text 330 118 calculated from 100000 steps; #X text 330 100 some value distribution graphs for walks in [0 , N-1] ; #X text 87 331 min ---> 0 as time ---> inf; #X text 110 266 max ---> 10 as time ---> inf; #X text 329 355 self-centering-random-walk.pd (copyleft) 2007-08-10 ; #X text 329 372 Claude Heiland-Allen claudiusmaximus@goto10.org; #X connect 0 0 4 0; #X connect 1 0 2 0; #X connect 2 0 13 0; #X connect 2 1 14 0; #X connect 3 0 0 1; #X connect 4 0 18 0; #X connect 4 1 12 0; #X connect 5 0 6 0; #X connect 6 0 7 0; #X connect 6 1 5 1; #X connect 8 0 9 0; #X connect 8 1 15 1; #X connect 11 0 16 0; #X connect 12 0 3 0; #X connect 12 1 1 0; #X connect 12 2 2 1; #X connect 13 0 3 1; #X connect 14 0 3 1; #X connect 15 0 8 0; #X connect 16 0 0 0; #X connect 17 0 16 1; #X connect 18 0 10 0; #X connect 18 1 15 0; #X connect 18 2 5 0; #X connect 21 0 19 0; #X connect 23 0 26 0; #X connect 25 0 27 0;
On Thu, 2007-05-10 at 03:17 +0100, Claude Heiland-Allen wrote:
Here's an example of a random walk that is biased towards the middle of its range and is guaranteed not exceed its bounds.
Hope someone finds it useful, I'm using it for melodies in a generative piece (I'll publish the full patch in a couple of weeks).
Any statisticians want to analyse it further than I have? Anyone have any suggestions for improvements?
That's a really useful patch. Connecting the output multiplied by a constant to the right inlet of the metro is a really simple way to create some rhythmic interest!
Two questions:
after [random] ?
need to have names that are unique to the enclosing root canvas?
Jamie
Hallo, Jamie Bullock hat gesagt: // Jamie Bullock wrote:
Two questions:
- What are the arrays for? Are they intended for some kind of mapping
after [random] ?
I guess they are just used to visualize the self-centering of the walking process
- Why do you use $0- for the subpatches, is there some reason why they
need to have names that are unique to the enclosing root canvas?
Claude is supercautious here, but it's a good habit IMO: Subpatches, like tables, create automatic receiver targets called "pd-NAME-OF-SUBPATCH". Using $0 here will make sure, that the receiver is local to the currently opened patch: "pd-$0-NAME".
Otherwise a message like:
[clear( | [s pd-NAME-OF-SUBPATCH]
issued from somewhere in your running Pd will clear ever subpatch with the same name, which might not be what you want.
Frank Barknecht _ ______footils.org_ __goto10.org__
Hi Claude.
Thanks for sharing this innovative concept I think its very usefull. Cant wait to hear how you use it
Attached patch is my way of making centered random.
mhv/ (kind regards) Steffen Leve Poulsen
Claude Heiland-Allen skrev:
Here's an example of a random walk that is biased towards the middle of its range and is guaranteed not exceed its bounds.
Hope someone finds it useful, I'm using it for melodies in a generative piece (I'll publish the full patch in a couple of weeks).
Any statisticians want to analyse it further than I have? Anyone have any suggestions for improvements?
Claude
#N canvas 108 44 738 515 10; #X obj 46 163 tabwrite vu; #X obj 46 136 + 1; #X obj 46 98 tabread vu; #X obj 46 64 t f f; #N canvas 0 0 450 300 (subpatch) 0; #X array vu 1000 float 2; #X coords 0 99 1000 0 200 140 1; #X restore 398 177 graph; #X obj 46 -25 until; #X msg 106 -53 ; vu const 0; #X obj 46 21 expr (random(1000 , 0)+random(1000 , 0)+random(1000 , 0))/3; #X msg 46 -53 100000; #X connect 1 0 0 0; #X connect 2 0 1 0; #X connect 3 0 2 0; #X connect 3 1 0 1; #X connect 5 0 7 0; #X connect 7 0 3 0; #X connect 8 0 5 0;
Claude Heiland-Allen wrote:
Hope someone finds it useful, I'm using it for melodies in a generative piece (I'll publish the full patch in a couple of weeks).
As promised, here's the patch (tested with vanilla pd-0.40-2, no externals required):
https://devel.goto10.org/dl.php?repname=maximus&path=%2Ftwins%2F&rev...
(If you're not sure how to unpack the archive on Windows, try 7-zip)
On 5/9/07, Claude Heiland-Allen claudiusmaximus@goto10.org wrote:
Here's an example of a random walk that is biased towards the middle of its range and is guaranteed not exceed its bounds.
Hi, Claude, I came up with something similar, a random walk biased towards 0, as a signal object. The parameters are awful tricky/finicky. I don't have any good guidelines for choosing the parameters to make it work more effectively, just trial and error. The patch simulates a 1st order stochastic differential equation (in a crude fashion). If anyone can suggest a good way to simulate these kind of equations, I would like to know more :) Chuck