Files
mikoto10032--deeplearning/books/PRML/PRMLT-master-MATLAB/common/randp.m
T
2026-07-13 13:30:25 +08:00

4 lines
114 B
Matlab
Executable File

function i = randp(p)
% Sample a integer in [1:k] with given probability p
i = find(rand<cumsum(normalize(p)),1);