From 061e4be1f20ac78e3b52bc6429322d5fadcf5831 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 28 Apr 2005 00:25:05 +0000 Subject: cleaned up a number of patches; renamed all to the standard -help.pd format; added some more ideas to the style guide; finished up lists_vs_anythings svn path=/trunk/; revision=2841 --- doc/pddp/random-help.pd | 182 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 doc/pddp/random-help.pd (limited to 'doc/pddp/random-help.pd') diff --git a/doc/pddp/random-help.pd b/doc/pddp/random-help.pd new file mode 100644 index 00000000..6f74d6f7 --- /dev/null +++ b/doc/pddp/random-help.pd @@ -0,0 +1,182 @@ +#N canvas 14 -1 978 651 10; +#X obj 20 11 random; +#X text 70 11 - pseudorandom integer generator; +#X text 20 47 [random] outputs pseudorandom integers between 0 and +N-1 where N is the creation argument or the value of the right inlet. +; +#X obj 28 117 random 100; +#X obj 28 98 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 28 138 3 0 0; +#X text 98 117 Generates random numbers between 0 and 99; +#X obj 28 178 random 100; +#X obj 28 159 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 28 199 3 0 0; +#X floatatom 83 161 5 0 0; +#X text 124 159 Changes the 'range' of random numbers.; +#X text 17 223 SEEDS; +#X text 21 240 Random numbers are generated via a complex equation +which produces a pseudo-predictable sequence of numbers. Each [random] +object's equation is provided with a "seed" which is really just one +of the variables in the equation which produces the sequence. The "seed" +is generated by Pd based on specific parameters in each patch which +contains a [random] object. If more than one [random] objects are contained +within a single patch \, they each get a different "seed".; +#X text 21 363 However \, "seeds" can be inputted into [random] by +sending a message \, like below:; +#X msg 13 420 seed 42; +#X obj 67 427 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 67 445 random 1000; +#X floatatom 67 465 3 0 0; +#X obj 13 400 loadbang; +#X text 22 490 Seeds are kept locally so that if two [random]s are +seeded the same \, they will have the same output - as demonstrated +below. Furthermore \, you can seed the same one twice to repeat the +output.; +#X msg 162 556 seed 42; +#X obj 76 559 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 76 591 random 1000; +#X floatatom 76 611 3 0 0; +#X obj 162 536 loadbang; +#X obj 150 591 random 1000; +#X floatatom 150 611 3 0 0; +#X obj 385 12 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 385 620 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 425 18 FERTILE SEEDS!; +#X text 416 39 While the "default" seed for each [random] is usually +very effective \, it may be necessary to find better - more unpredictable +- more indeterminate ways to seed the object to produce a more pleasing +result.; +#X text 415 144 Here are some ideas that may improve the implementation +of [random]:; +#X floatatom 593 241 0 0 0; +#X obj 435 182 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 593 221 / 100; +#X floatatom 435 238 0 0 0; +#X text 455 181 Both methods here produce random numbers between 0 +and 5; +#X obj 593 201 random 501; +#X obj 435 218 random 6; +#X text 660 201 0 - 500; +#X text 631 221 divide by 100 to keep output within range.; +#X text 631 242 produces fractional results between 0 and 5; +#X text 432 269 between 0 and 5; +#X text 432 256 Produces whole numbers; +#X text 401 179 1; +#X text 405 306 2; +#X text 416 94 As well \, there are many ways that [random] can be +incorporated into other structures that change the qualities of the +results.; +#X obj 436 315 loadbang; +#X obj 436 337 timer; +#X obj 518 318 bng 15 250 50 0 empty empty Click_to_seed 0 -6 0 7 -262144 +-1 -1; +#X msg 436 357 seed \$1; +#X obj 497 360 bng 15 250 50 0 empty empty Click_for_output 0 -6 0 +7 -262144 -1 -1; +#X floatatom 497 400 5 0 0; +#X obj 497 379 random 42; +#X text 598 317 "Time is on your side". Using the [timer] object here +(which is started via loadbang) is an interesting trick.; +#X text 407 432 3; +#N canvas 0 0 462 404 weighted_random_numbers 0; +#X msg 38 77 bang; +#X text 24 20 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 38 103 random 100; +#X obj 37 156 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 104 156 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 140 130 3 0 100; +#X text 185 130 <-- change probablilty; +#X obj 38 131 moses 80; +#X text 87 75 <-- click to test; +#X text 35 184 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 42 247 bang; +#X obj 42 273 random 100; +#X obj 42 326 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 132 327 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 91 245 <-- click to test; +#X obj 42 301 moses 10; +#X obj 132 302 moses 30; +#X obj 200 327 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 40 342 10%; +#X text 130 343 20%; +#X text 202 342 70%; +#X connect 0 0 2 0; +#X connect 2 0 7 0; +#X connect 5 0 7 1; +#X connect 7 0 3 0; +#X connect 7 1 4 0; +#X connect 10 0 11 0; +#X connect 11 0 15 0; +#X connect 15 0 12 0; +#X connect 15 1 16 0; +#X connect 16 0 13 0; +#X connect 16 1 17 0; +#X restore 443 432 pd weighted_random_numbers; +#X text 215 556 Click again to repeat output.; +#X text 409 474 RELATED OBJECTS; +#N canvas 0 0 454 304 related_objects_from_other_libraries 0; +#X obj 25 23 randomF; +#X obj 77 23 tripleRand; +#X obj 146 23 shuffle; +#X obj 197 23 mtx_rand; +#X obj 149 47 pin~; +#X obj 25 47 randomblock~; +#X obj 109 47 utime; +#X text 29 104 These objects are offered in Pd only if you have downloaded +and properly installed the appropriate library. These objects may or +may not exist in a single library.; +#X text 28 153 The best places to find information about Pd's libraries +is:; +#X text 25 175 www.puredata.org and click on "Downloads" then "Software" +; +#X text 27 190 or; +#X text 27 205 iem.kug.ac.at/pdb/; +#X restore 408 494 pd related_objects_from_other_libraries; +#X text 416 592 This document was updated for Pd version 0.35 test +29 by Dave Sabine as part of a project called pddp proposed by Krzysztof +Czaja to build comprehensive documentation for Pd.; +#X connect 3 0 5 0; +#X connect 4 0 3 0; +#X connect 7 0 9 0; +#X connect 8 0 7 0; +#X connect 10 0 7 1; +#X connect 15 0 17 0; +#X connect 16 0 17 0; +#X connect 17 0 18 0; +#X connect 19 0 15 0; +#X connect 21 0 23 0; +#X connect 21 0 26 0; +#X connect 22 0 23 0; +#X connect 22 0 26 0; +#X connect 23 0 24 0; +#X connect 25 0 21 0; +#X connect 26 0 27 0; +#X connect 28 0 29 0; +#X connect 34 0 38 0; +#X connect 34 0 39 0; +#X connect 35 0 33 0; +#X connect 38 0 35 0; +#X connect 39 0 36 0; +#X connect 48 0 49 0; +#X connect 49 0 51 0; +#X connect 50 0 49 1; +#X connect 51 0 54 0; +#X connect 52 0 54 0; +#X connect 54 0 53 0; -- cgit v1.2.1