[Thread Prev][Thread Next][Index]

Re: [ferret_users] shuffle or how to permute randomly elements



Andrew Wittenberg a écrit :
Hi Patrick,

To shuffle a time series, simply sample your vector with indices that sort
a random array:

   let a_shuffle = samplel(a,sortl(randu(a)))

An example with multiple shuffles:

   let a = tsequence({100,500,600,20,90,4})
   let seeds = {101,102,103}
   let a_shuffle = samplel(a,sortl(randu(tcat(seed,a[l=2:`a,r=lsize`]))))
rep/name=s/range=1:`seeds,r=isize` (let seed = seeds[i=`s`]; list a_shuffle)
Nice Andrew.
Thanks very much on this one.

Patrick



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement