[PD] help_random/seed

Martin Peach martin.peach at sympatico.ca
Mon Jul 6 05:14:43 CEST 2009


Ian Andrews wrote:
> Just an ignorant assumption, but would not the output of [noise~] itself 
> be generated from pseudo-random numbers? If not, then how does [noise~] 
> generate its randomness? Or is there something more complex at work?
> 

Yes it's currently also a pseudo-random source. In fact it is this (from 
d_osc.c):

static t_int *noise_perform(t_int *w)
{
     t_sample *out = (t_sample *)(w[1]);
     int *vp = (int *)(w[2]);
     int n = (int)(w[3]);
     int val = *vp;
     while (n--)
     {
         *out++ = ((float)((val & 0x7fffffff) - 0x40000000)) *
             (float)(1.0 / 0x40000000);
         val = val * 435898247 + 382842987;
     }
     *vp = val;
     return (w+4);
}

...which is a deterministic chaos generator.
But if you were to resample an oscillator that it's driving at a much 
lower rate then you would get more entropy, so it seems more random, but 
at the cost of losing a lot of samples.

Martin


> Ian
> 
> On 05/07/2009, at 7:12 PM, Andrew Faraday wrote:
> 
>>
>> Just an idea, but if the hardware random number generators use a 
>> jittery oscillator etc. Why not use [noise~] and [snapshot~] followed 
>> by some arithmetic and [int] you could build what I assume would be 
>> more random than the [random] box.
>>
>> Andrew
>>
>> > Date: Sun, 5 Jul 2009 00:22:51 -0400
>> > From: martin.peach at sympatico.ca <mailto:martin.peach at sympatico.ca>
>> > To: mmoserbooth at gmail.com <mailto:mmoserbooth at gmail.com>
>> > CC: pd-list at iem.at <mailto:pd-list at iem.at>; zmoelnig at iem.at 
>> <mailto:zmoelnig at iem.at>
>> > Subject: Re: [PD] help_random/seed
>> > 
>> > Mike Moser-Booth wrote:
>> > > IOhannes m zmölnig wrote:
>> > >> Frank Barknecht wrote:
>> > >>> Hallo,
>> > >>> cem guney hat gesagt: // cem guney wrote:
>> > >>>
>> > >>>> just started studying PD. going through the control examples i've 
>> > >>>> been stuck trying to figure out the function of the message, seed 
>> > >>>> 123 in the
>> > >>>> example for "random". not sure if i figured out the explanation below,
>> > >>>>
>> > >>>> Seeds are kept locally so that if two Randoms are seeded the same 
>> > >>>> they will have the same output (or indeed you can seed the same one 
>> > >>>> twice to repeat the output.)
>> > >>>
>> > >>> Yes, that's true, you understood correctly.
>> > >>>
>> > >>> Oh, wait, that's what's in the help-file! What exactly is cloudy there?
>> > >>
>> > >> probably the simple fact, that [random] despite of it's name does not 
>> > >> really produce random numbers.
>> > >> mostly when computers present you a "random" number, then this number 
>> > >> will only appear to be random, but in reality is just calculated as 
>> > >> the next item of a totally deterministic series.
>> > >> (as a matter of fact, a new random number is usually generated by 
>> > >> simple taking the last number and then applying some more or less 
>> > >> complicated transformation on this number). this method is known as 
>> > >> "pseudo random".
>> > >>
>> > >> you can set the "starting point" of the series by setting the "seed", 
>> > >> which is the first number of the random sequence). since all [random] 
>> > >> object use the same algorithm to calculate the next pseudo-random 
>> > >> number, they will all end up with the same sequence if they all start 
>> > >> with the same "seed".
>> > >> by default Pd uses different seeds for all [random] objects so they 
>> > >> all appear to work independently.
>> > > In addition, it's probably worth mentioning that Pd will produce the 
>> > > same seeds for each [random] every time you load the patch. So while 
>> > > they appear to work independently, you will still get the same results 
>> > > each time you first run a patch after loading it.
>> > > 
>> > 
>> > A lot of the latest cpus have hardware random number generators that 
>> > work by having a jittery oscillator sample the cpu clock, or something 
>> > along those lines. (Such a jittery oscillator is assumed to have 
>> > normally distributed transition times.)
>> > It would be nice if the random source could be independently specified 
>> > for all the pd objects that use random numbers, since the count of 
>> > unreachable combinations when using the standard deterministic chaos 
>> > generators is infinite.
>> > 
>> > Martin
>> > 
>> > 
>> > _______________________________________________
>> > Pd-list at iem.at <mailto:Pd-list at iem.at> mailing list
>> > UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
>>
>> ------------------------------------------------------------------------
>> Upgrade to Internet Explorer 8 Optimised for MSN. Download Now 
>> <http://extras.uk.msn.com/internet-explorer-8/?ocid=T010MSN07A0716U> _______________________________________________
>> Pd-list at iem.at <mailto:Pd-list at iem.at> mailing list
>> UNSUBSCRIBE and account-management 
>> -> http://lists.puredata.info/listinfo/pd-list
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Pd-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list





More information about the Pd-list mailing list