On Tue, 29 Jan 2008, andreas.rosenblad(a)ltv.se wrote:
However, I still think it should be included natively in gretl
by extending the resample() command so that it can be used with
mxn matrices too. It would be easier, more natural and less
error-prone to use B = resample(A) instead of writing special
code every time.
But B = resample(A) won't do the job you were asking for; you'd
need at least one additional parameter, perhaps mpre.
The actual "active ingredient" in what I posted is just a
one-liner,
matrix B = A[int(muniform(R,1)*T+1)]
and this is very flexible since you can vary independently the
number of draws (R) and the number of rows of A to draw from (T).
In fact, you don't even need the "int()", that is implicit:
matrix B = A[muniform(R,1)*T+1]
I don't really see this as "writing special code".
This could be put in the "cheatsheet" chapter of the User's Guide.
All the same, I'll take a look at how easy it would be to extend
"resample" (in its simple form) for matrices.
Allin.