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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -