Sorry to answer a question with a question, but I have to ask...
Why do you need to ensure that the mean of your vector of random numbers is precisely same as your original vector? In a similar vein, why does the standard deviation need to be precisely the same?
If I run a monte carlo simulation or some such, I'm trying to discover what might happen.
If you adjust your random numbers so that the mean is precisely X and the standard deviation is exactly Y you're decreasing the chance that your simulation will contain an extreme event. In turn, this mean's that its less likely that something is going to go wrong.
These types of transforms are fine as an academic exercise, however, I'd have grave concerns about employing this type of method in the real world.
- You're defeating the whole purpose of your simulation
- If your methods are so sensitive that they won't work is the mean and standard deviation are off by some arbitrarily small amount this, in and of itself, should tell you something