On Tue, 24 Sep 2019, Sven Schreiber wrote:
Am 24.09.2019 um 15:49 schrieb Allin Cottrell:
> On Tue, 24 Sep 2019, Ioannis A. Venetis wrote:
> Thanks, Ioannis. Maybe this offers a way to break the current deadlock
> over msample? We could easily rejig msample as randperm (quite nice to
> have a Matlab-compatible function and no harm in using the same name)
> and then leave it up to users how exactly they want to employ it.
> The existing design use of msample on X (r x c), as in
> matrix s = msample(X, n)
> would become
> matrix s = X[randperm(r,n),]
My personal taste is that the r feels redundant here -- in the sense
that there's a good reason it doesn't appear in the msample variant.
Having X as a function argument avoids this. What about randperm(X,n)?
In that case we'd be back with my msample(), but misleadingly renamed
If your purpose is just selecting n rows from some X, it's true that
using randperm requires an extra term, as illustrated in the
comparison above, but the advantage of randperm is that it's more
Consider the case I mentioned of a subsample without replacement with
s = X[sort(randperm(r, n)),]
To get this with the 'X' argument you'd have to insert a redundant
s = X[sort(randperm(seq(1,r)', n),]
Another case of flexibility: take a subsample of the top half of X:
s = X[randperm(r/2, n),]