Dear all,
I am facing the following simple problem for which I only find a loop
solution but loops are (generally?) slow compared to vectorized
approaches (if possible).
<hansl>
matrix Y = seq(1,10)' # original realizations
SEL = ceil(muniform(10,1)*10) # selection vector (select i-th row
from Y)
eval Y ~ SEL
matrix X = zeros(10,1) # put re-sampled Y values here
# I want to avoid this annoying loop...
loop i=1..rows(SEL) -q
catch X[i]=A[SEL[i]] # i-th position Y value
endloop
</hansl>
In MATLAB this works simply by: X = Y(SEL)
Is there any way to vectorize this task?? Thanks in advance.
Artur