# Computer Science (MATLAB)

posted by Jhon

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.

## Similar Questions

Given the numerical values shown for the function f(x), find approximate values for the derivative of f(x) at each of the x-values given. x= 0 1 2 3 4 5 6 7 8 f(x)= 13 15 16 17 17 14 11 9 7 f'(x)= 2 1 1 1 0 -3 -3 -2 -2 What seems to …
2. ### Computer Science - MATLAB

One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approach a number called “the golden ratio” or PHI. Create a program that accepts the first two numbers of a Fibonacci …
3. ### Computer Science - MATLAB

I guess it was skipped One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approach a number called “the golden ratio” or PHI. Create a program that accepts the first …
4. ### probability

out of 250 students interviewed at a community college, 90 were taking mathematics but not computer science, 160 were taking mathematics, and 50 were taking neither mathematics nor computer science. Find the probability that a student …
5. ### Computer Science (MATLAB)

I had a test in my computer science course in which I was asked if any while loop can be replaced with a for loop. I put true. I guess the answer was false. My professor said that if you had a while loop in which you asked the user …
6. ### Computer Science (MATLAB)

I had a test in my computer science course in which I was asked if any while loop can be replaced with a for loop. I put true. I guess the answer was false. My professor said that if you had a while loop in which you asked the user …
7. ### calculus

Find a unit vector U such that the rate of change of f in the direction of U at the given point is maximum. point being (3,5,pi) I know hos to do this when given a direction but since im asked to ind the unit vector first it kinda …
8. ### Probability

The newest invention of the 6.041x staff is a three-sided die. On any roll of this die, the result is 1 with probability 1/2, 2 with probability 1/4, and 3 with probability 1/4. Consider a sequence of six independent rolls of this …
9. ### bio statistics question!

Does P(x) = x/5, where x can take values of 0, 1, 2, 3, describe a probability distribution?
10. ### Math

Given P(A) = m is the probability of event A occurring in any given trial: 1. State the range of possible values of m 2. Suppose two trials are performed independently. Find, in terms of m, the probability of A occurring: a) Exactly …

More Similar Questions