Randomly remove percentage of values above mean in array
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Say I have an array containing a set of values. How can I randomly remove 20% of the values ABOVE the mean while keeping the order the same?
Right now I have the following code completed, but this only returns an array containing 80% of the values above than the mean, I would like to have an array containing both the original data that is BELOW the mean AND the array containing 80% of the values above than the mean. In theory, this should result in randomly removing 20% of the values above the mean, however, I just can't figure out how to implement it. Any help is appreciated. I'm open to other ways of implementing this as well.
A = [set of values];
index1 = find(A>mean(A));
A_mod = A(index1);
[A_rem, idx_mod] = datasample(A_mod,round(0.80*length(A)));
1 comentario
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!