[R] random value changes in a vector

Salas, Andria Kay aks2515 at uncw.edu
Tue Nov 18 18:11:05 CET 2008


To clear up a question regarding my earlier posting regarding random changes in a vector:

Say you have a vector (1, -1, -1, 1, 1, -1).  I want each value in the vector to have a probability that it will change signs when this vector is regenerated.  For example, probability = 50%.  When the vector is regenerated, the first value in the vector (1) has a 50% chance of switching to -1.  If I regenerated this vector 10 times, 5 of the times it would switch to -1.  Similarly, I need each value in the vector to have this same probability of switching signs when the vector is regenerated, and each value's chances of doing so is independent of the other values.  So the second value (-1) also has a 50% chance of switching to 1, and whether or not it does so is independent of if the first value changes from 1 to -1 (also a 50% probability). 

 I hope this clears up the confusion, and I would appreciate any help anyone can provide!


More information about the R-help mailing list