We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The matrix approach is much faster than the sampling approach.
probabilities <- matrix(runif(1000000), 100000, 10) probabilities_ <- probabilities - runif(100000 * 10) ind_sapply <- sapply(1:nrow(probabilities), function(i) sample(1:10, 1, prob = probabilities[i,])) ind_mat <- max.col(probabilities_, 'first') table(ind_sapply) table(ind_mat) Unit: milliseconds expr min lq mean sapply(1:nrow(probabilities), function(i) sample(1:10, 1, prob = probabilities[i, ])) 469.872150 619.764793 656.780946 max.col(probabilities_, "first") 1.955379 2.209599 2.308426 median uq max neval cld 655.096765 686.15894 1047.475831 100 b 2.270803 2.36885 2.911497 100 a
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The matrix approach is much faster than the sampling approach.
The text was updated successfully, but these errors were encountered: