You have a completely wrong understanding how expressions in AE work. There is no such think as global variables and the return value is always the absolute value of the property stream, nothing more, regardless whether it's generated by keyframes, expressions or a combination of one on top of the other. If the code is part of a larger construct, then you need to post the code in its entirety. Otherwise nothing stops you from generating the random values on a separate expression control if it needs to be re-used by multiple other expressions. Again, you simply have things backwards.
Mylenium