[PD] Random number generation quest
Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number Thanks for looking into it eni ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
On Wed, 2012-11-14 at 14:53 +, Enrique Erne wrote: Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number If you happen to start Pd always from bash / command-line, you do something like this: pd -noprefs -nogui givemerandom.pd -send seed $RANDOM and in your patch: [r seed] | [seed $1( | [random] However, I also would be interested in a solution that works without command-line arguments. Roman ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
Hi, You could use the [shell] object to run a little bash script that would ask the current time in milliseconds from your system, and send it as a seed to Pd using pdsend. This way you wouldn't need any extra command line arguments. I don't know whether this is worth the trouble, though. Pierre. 2012/11/14 Roman Haefeli reduz...@gmail.com On Wed, 2012-11-14 at 14:53 +, Enrique Erne wrote: Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number If you happen to start Pd always from bash / command-line, you do something like this: pd -noprefs -nogui givemerandom.pd -send seed $RANDOM and in your patch: [r seed] | [seed $1( | [random] However, I also would be interested in a solution that works without command-line arguments. Roman ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
On 14/11/12 15:53, Enrique Erne wrote: Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number Something like the attached should do it... But as someone already pointed out is it really worth it? Why not just do something like (assuming you have BASH): echo $[ $RANDOM % 100] Lorenzo. #N canvas 560 444 657 443 10; #X obj 137 -24 loadbang; #X obj 139 233 random 100; #X obj 249 -16 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X msg 191 356 \; pd-givemerandom.pd menusave 1; #X obj 191 299 del 10; #N canvas 0 0 450 300 (subpatch) 0; #X array array1 1 float 3; #A 0 25; #X coords 0 1000 1 0 200 140 1 0 0; #X restore 426 231 graph; #X obj 274 202 tabwrite array1; #X msg 361 175 1; #X obj 289 55 tabread array1; #X msg 289 27 1; #X obj 274 125 f; #X obj 302 125 + 1; #X obj 139 264 t f b; #X obj 137 -1 t b b b b; #X msg 387 124 0; #X obj 274 151 t f f b; #X msg 209 202 seed \$1; #X text 421 124 manual reset; #X text 473 206 Y range set from 0 to 1000; #X text 388 29 'load' the stored seed; #X text 244 219 add +1 and use as seed \; also save to array; #X text 190 390 save the patch (and with it the array...); #X floatatom 339 87 5 0 0 0 - - -; #X obj 140 332 print RANDOM; #X connect 0 0 13 0; #X connect 1 0 12 0; #X connect 2 0 13 0; #X connect 4 0 3 0; #X connect 7 0 6 1; #X connect 8 0 10 1; #X connect 8 0 22 0; #X connect 9 0 8 0; #X connect 10 0 11 0; #X connect 10 0 15 0; #X connect 11 0 10 1; #X connect 12 0 23 0; #X connect 12 1 4 0; #X connect 13 0 1 0; #X connect 13 1 10 0; #X connect 13 2 10 0; #X connect 13 3 9 0; #X connect 14 0 15 0; #X connect 15 0 16 0; #X connect 15 1 6 0; #X connect 15 2 7 0; #X connect 16 0 1 0; ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
Hi Is the [time] object in pd-vanilla? If so you could use the milliseconds output as your seed... [loadbang] |[time]| (milliseconds) [random] Date: Wed, 14 Nov 2012 14:53:44 + From: enri...@netpd.org To: pd-list@iem.at Subject: [PD] Random number generation quest Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number Thanks for looking into it eni ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
Le 14/11/2012 18:30, Andrew Faraday a écrit : Hi Is the [time] object in pd-vanilla? If so you could use the milliseconds output as your seed... [loadbang] | [time] | (milliseconds) [random] Date: Wed, 14 Nov 2012 14:53:44 + From: enri...@netpd.org To: pd-list@iem.at Subject: [PD] Random number generation quest Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number Thanks for looking into it eni ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list Yep, but the first requirement for Enrique was : - No externals / Vanilla Pd only So it doesn't work with zexy [time] (this not in Pd Vanilla ;). ++ Jack ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
On Wed, 14 Nov 2012 15:53:44 +0100, Enrique Erne enri...@netpd.org wrote: Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number Thanks for looking into it eni ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list Here's a solution using [realtime] and [del] #N canvas 539 577 450 300 10; #X obj 184 51 loadbang; #X obj 184 125 realtime; #X obj 184 74 t b b; #X msg 211 195 seed \$1; #X obj 184 96 del 5; #X obj 184 148 * 1000; #X obj 184 250 print; #X obj 184 171 t b f; #X obj 184 219 random 100; #X connect 0 0 2 0; #X connect 1 0 5 0; #X connect 2 0 4 0; #X connect 2 1 1 0; #X connect 3 0 8 0; #X connect 4 0 1 1; #X connect 5 0 7 0; #X connect 7 0 8 0; #X connect 7 1 3 0; #X connect 8 0 6 0; ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
Here's one that works in real time by building a subpatch with some objects, measuring that time, using that measurement to create and clear the subpatch anywhere from 0-9 more times, then multiplying the sum of all this time for the seed to [random]. Obviously if you create a complex object like [sigmund~] you'd get more variance but also a longer load time. It looks to take less than a millisecond in the worst case for my version, but I don't know how random my randomness is. Does someone have a tool to measure how random these approaches are? -Jonathan - Original Message - From: Kaj Ailomaa zeque...@mousike.me To: pd-list@iem.at Cc: Sent: Wednesday, November 14, 2012 3:24 PM Subject: Re: [PD] Random number generation quest On Wed, 14 Nov 2012 15:53:44 +0100, Enrique Erne enri...@netpd.org wrote: Hi List! Can a random number form 0 to 100 be generated with the following requirements: - No externals / Vanilla Pd only - DSP must be off - The patch is loaded with Pd through command line interface i.e. `pd -noprefs -nogui givemerandom.pd` - The output should not always be the same number Thanks for looking into it eni ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list Here's a solution using [realtime] and [del] #N canvas 539 577 450 300 10; #X obj 184 51 loadbang; #X obj 184 125 realtime; #X obj 184 74 t b b; #X msg 211 195 seed \$1; #X obj 184 96 del 5; #X obj 184 148 * 1000; #X obj 184 250 print; #X obj 184 171 t b f; #X obj 184 219 random 100; #X connect 0 0 2 0; #X connect 1 0 5 0; #X connect 2 0 4 0; #X connect 2 1 1 0; #X connect 3 0 8 0; #X connect 4 0 1 1; #X connect 5 0 7 0; #X connect 7 0 8 0; #X connect 7 1 3 0; #X connect 8 0 6 0; ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list time-waster.pd Description: Binary data ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list
Re: [PD] Random number generation quest
i used something like kaj posted. It seemed to work ok. ___ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management - http://lists.puredata.info/listinfo/pd-list