matlab - Weighted sampling with 2 vectors -
(1) have 2 column vectors.
eg. x = [283167.778 *289387.207 289705.322] y = [9121643.314 9098348.666* 9099832.621]
(2) i'd make weighted random sampling using these vectors: when i'll select element 289387.207 in vector x, i'll choose element 9098348.666 in vector y.
(3) also, have weighted w vector each element in vector x , y.
how can implement in matlab? thanks!
for random selection:
sel_idx= randi(3); outputx = x(sel_idx); outputy = y(sel_idx);
for random weighing:
w = rand(size(x)); w = w./sum(w); % normalize outputx = w(:)'*x(:); outputy = w(:)'*y(:);
Comments
Post a Comment