function s = randweightedsample(p,n,w)
%Ekta Gujral,Ravdeep Pasricha , Vagelis Papalexakis 2017
%Computer Science and Engineering, University of California, Riverside
%Demonstrating the use of the SambaTen algorithm, using samplaing based
%approach for online tensors
n = ceil(n);
nnz_w = nnz(w);
n = min([n nnz_w]);%this guard makes sure that we always have data to sample from
s = zeros(n,1);
uniq=0;
finalsample=zeros(n,1);
s=datasample(p,n,'Replace',false,'Weights',w);

end
