On Tue, 17 Sep 2019, Ioannis A. Venetis wrote:
I agree Artur. I was recently in need for a resample without
replacement
function.
I have not check your code but I had a look on what I did and it could
be a refinement (following also Sven's answer).
Say a matrix A is nxm.
set k<=m.
rvec = ranking( mrandgen(u,0,1,m,1) )'
A=[,rvec[1:k]]
(keeps k randomly selectled columns of A)
I would like to see such a function in extra.gfn
I like it. We could have something like this in extra.gfn:
<hansl>
function matrix sample_wo_rep(matrix X, scalar k)
scalar n = rows(X)
if k > n
funcerr "what?"
endif
matrix sel = ranking(muniform(n,1))
return X[sel[1:k],]
end function
### example
X = mnormal(10, 3)
print X
eval sample_wo_rep(X, 6)
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------