- #1
GreenPrint
- 1,196
- 0
MatLab Question
Given a vector of values of zeros and ones such as [1 0 1 0 0 0 1 0] I'm asked to, given a probability provided by the user, use that probability to change the values in the vector using that probability.
For example given the vector [0 1 0 0 0 1 0 0 0 1] and probability .2 provided by the user there is a 20% chance that the values in the vector will change (either from 0 to 1 or 1 to 0) or that there's a good chance that a vector of 10 values 2 values in that vector will change.
I'm asked to create a function to do this and kind of confused how to do this with the probability of changing the values (apparently I have to use rand function which I know how to use just kind of lost how to do this)
I assume that I would have to take each value within the vector (there will be exactly 8 values in the vector) and doing something to each of these values with the probability and changing them from the current value to the one it is not (either 1 or 0).
I'm kind of lost. Thanks for any help which you can provide.
Given a vector of values of zeros and ones such as [1 0 1 0 0 0 1 0] I'm asked to, given a probability provided by the user, use that probability to change the values in the vector using that probability.
For example given the vector [0 1 0 0 0 1 0 0 0 1] and probability .2 provided by the user there is a 20% chance that the values in the vector will change (either from 0 to 1 or 1 to 0) or that there's a good chance that a vector of 10 values 2 values in that vector will change.
I'm asked to create a function to do this and kind of confused how to do this with the probability of changing the values (apparently I have to use rand function which I know how to use just kind of lost how to do this)
I assume that I would have to take each value within the vector (there will be exactly 8 values in the vector) and doing something to each of these values with the probability and changing them from the current value to the one it is not (either 1 or 0).
I'm kind of lost. Thanks for any help which you can provide.
Last edited: