How do I sample a random value from a matrix?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ethan Correa
el 2 de Mayo de 2018
Comentada: Ethan Correa
el 2 de Mayo de 2018
Let's say I have a random matrix:
A = rand(10,4)
How can I sample a random value from this matrix (without replacement)? Essentially how can I perform a randsample but for a matrix instead of a vector?
0 comentarios
Respuesta aceptada
Akira Agata
el 2 de Mayo de 2018
If you want to obtain k samples randomly from A, the following will do that.
ind = randperm(numel(A),k);
output = A(ind);
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!