[Thread Prev][Thread Next][Index]

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



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)

Andrew

On Tue, 25 Jan 2011, Patrick.Brockmann@xxxxxx wrote:

Hi all,

I have coded a ferret script where 2 variables are
co-plotted with coloring samples with their latitudes.

It can be easilly achieved with the script polymark.
yes? go polymark
polygon/over/nolab/key/lev=(-90,90,10)/pal=centered/nolab/fill
w1,w2,w3,circle,0.5
No problem there. See 1st figure attached.

But as I worked from 2D variables, when I vectorize them,
I conserve their underlaying grid.

For now, I have done this using an external call to python/numpy

yes? go shuffle 10
yes? list shuffle
            VARIABLE : SHUFFLE
            FILENAME : shuffle.txt
            SUBSET   : 10 points (X)
1    /  1:   3.00
2    /  2:  10.00
3    /  3:   8.00
4    /  4:   4.00
5    /  5:   7.00
6    /  6:   6.00
7    /  7:   5.00
8    /  8:   1.00
9    /  9:   2.00
10   / 10:   9.00

Applying this shuffle to my samples with the
ferret samplei(v1, shuffle) gives me what I was
expecting (independant sample over their latitudes).
yes? go polymark
polygon/over/nolab/key/lev=(-90,90,10)/pal=centered/nolab/fill
samplei(w1,shuffle),samplei(w2,shuffle),samplei(w3,shuffle),circle,0.5
See fig2 attached.

I am wondering if a shuffle function could be added to ferret ?
Any news to share about link between python and ferret ?


Patrick



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

Privacy Policy | Disclaimer | Accessibility Statement