mercredi 22 juin 2016

Index position of randsample in Matlab

I'm using the randsample function of Matlab to sample a data point in the following way:

points = randi(100,1,10);
weighting_vector = rand(1,10);
normalized_weighting_vector = weighting_vector ./ sum(weighting_vector);
point = randsample(points,1,'true',normalized_weighting_vector);

How can I get the index of the selected point?

For example if points = [1,2,2,3,4,4,4,8,9,3] and point = 4, I would like to know the index position of the chosen value, which can either be 5, 6 or 7.




Aucun commentaire:

Enregistrer un commentaire