I am simulating resistance of my theoretical model against missing data and for that reason want to randomly set a specified fraction (e.g. 20%) of all numerical values in a 2 dimensional matrix (approx. 200×10000) to NaN. The matrix already has NaN cells (with no particular distribution in the original Matrix) due to the nature of the input format (so NOT representing missing data) that I would like to exclude from calculation for that process.
I would like to be able to set that fraction accurately, so calculating the total fraction of NaN already in the matrix before and increasing the fraction later used by the random generator doesn't work as a simple workaround.
Is there a process I could use to achieve this? Thanks!
Best Answer