loops - How to apply a probability to a cell in MATLAB? -


just simple question today. if have m*n matrix , want cycle through every value in , apply probability based function.

basically, if probability p, each value in matrix has p chance of having function applied it.

i have loop , function worked out, haven't found how apply probability itself.

any advice appreciated! in advance.

the trick can generate random numbers first, , apply other formulas.

for example:

r = rand(m,n) < p

now each value of r(row,col) corresponds outcome need process original matrix(row,col).


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -