Etienne,

The result from sampleRandom is as in sample (i.e. random cells in random
order), except when the sample size 's' is > 0.5 * ncells(raster), in which
case you get random cells in cell-order. This is because if s > 0.5, the
function takes a sample of size (1-s) and returns 1:ncell(raster)[-sample].
I think I can change that.

Robert

On Thu, Feb 9, 2012 at 11:14 AM, Etienne B. Racine <etiennebr@gmail.com>wrote:

> >
> > Isn't the more important question whether you saw documentation that is
> in
> > conflict with this behaviour?
> >
>
> Not really in conflict, it's just that I was expecting random order, like
> with sample(1:25). It was raising the issue about how the randomization was
> done. But I could indeed run sample(sampleRandom(r, 25)).
>
> I was expecting something like select all pixel index that !is.na() and
> run
> sample() on it. Though nothing suggests it in the doc. It was my own
> interpretation.
>
> Is it more accurate to say that the order isn't randomized, but pixels are
> picked randomly ? So for samples approching ncell(r), the sample isn't
> changing a lot.
>
> Etienne
>
> 2012/2/9 Edzer Pebesma <edzer.pebesma@uni-muenster.de>
>
> >
> >
> > On 02/09/2012 05:02 PM, Etienne B. Racine wrote:
> > > It seems that sampleRandom isn't so random.
> > >
> > > # try this :
> > > library(raster)
> > > r <- raster(matrix(1:25, 5, 5))
> > > sampleRandom(r, 25)
> > > ## 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15
> > > sampleRandom(r, 25)
> > > ## 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 5 10 15
> > >
> > > I haven't seen any documentation about this behavior.
> > >
> >
> > Isn't the more important question whether you saw documentation that is
> > in conflict with this behaviour?
> >
> > >
> > >       [[alternative HTML version deleted]]
> > >
> > > _______________________________________________
> > > R-sig-Geo mailing list
> > > R-sig-Geo@r-project.org
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> > --
> > Edzer Pebesma
> > Institute for Geoinformatics (ifgi), University of Münster
> > Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
> > 8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
> > http://www.52north.org/geostatistics      e.pebesma@wwu.de
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

	[[alternative HTML version deleted]]

