From 57045df5fe3ec557e57dc7434ac1a07b5521bffc Mon Sep 17 00:00:00 2001 From: Guenter Geiger Date: Mon, 29 Jul 2002 17:06:19 +0000 Subject: This commit was generated by cvs2svn to compensate for changes in r58, which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=59 --- pd/doc/2.control.examples/20.weighted-random.pd | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 pd/doc/2.control.examples/20.weighted-random.pd (limited to 'pd/doc/2.control.examples/20.weighted-random.pd') diff --git a/pd/doc/2.control.examples/20.weighted-random.pd b/pd/doc/2.control.examples/20.weighted-random.pd new file mode 100644 index 00000000..ed964a06 --- /dev/null +++ b/pd/doc/2.control.examples/20.weighted-random.pd @@ -0,0 +1,44 @@ +#N canvas 161 46 660 441 12; +#X msg 103 95 bang; +#X text 389 414 updated for Pd version 0.35; +#X text 44 19 You can generate weighted random numbers from uniformly +distributed ones. If you just want two possible outcomes with a varying +probability for each one \, you can do as shown:; +#X obj 103 121 random 100; +#X obj 102 174 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 169 174 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 205 148 3 0 100; +#X text 250 148 <-- change probablilty; +#X obj 103 149 moses 80; +#X text 152 93 <-- click to test; +#X text 61 219 This outputs a number at left 80% of the time \, otherwise +at right \, unless you override the "80" using the number box. You +may extend this to more than two possible outcomes \, for instance +like this:; +#X msg 106 305 bang; +#X obj 106 331 random 100; +#X obj 105 384 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 195 387 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 155 303 <-- click to test; +#X obj 106 359 moses 10; +#X obj 196 360 moses 30; +#X obj 263 387 bng 20 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 103 409 10%; +#X text 193 410 20%; +#X text 265 409 70%; +#X connect 0 0 3 0; +#X connect 3 0 8 0; +#X connect 6 0 8 1; +#X connect 8 0 4 0; +#X connect 8 1 5 0; +#X connect 11 0 12 0; +#X connect 12 0 16 0; +#X connect 16 0 13 0; +#X connect 16 1 17 0; +#X connect 17 0 14 0; +#X connect 17 1 18 0; -- cgit v1.2.1