about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/pick.m
diff options
context:
space:
mode:
Diffstat (limited to 'sourcecodes/bnt-master/KPMtools/pick.m')
-rw-r--r--sourcecodes/bnt-master/KPMtools/pick.m9
1 files changed, 9 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/KPMtools/pick.m b/sourcecodes/bnt-master/KPMtools/pick.m
new file mode 100644
index 00000000..8e40d937
--- /dev/null
+++ b/sourcecodes/bnt-master/KPMtools/pick.m
@@ -0,0 +1,9 @@
+function [i,j] = pick(ndx)
+% PICK Pick an entry at random from a vector
+% function [i,j] = pick(ndx)
+%
+% i = ndx(j) for j ~ U(1:length(ndx))
+
+dist = normalize(ones(1,length(ndx)));
+j = sample_discrete(dist);
+i = ndx(j);