Details:
To generate (pseudo) random numbers in range of -1 and 1 you can do the following:
In case your rand() function returns numbers between MININT / MAXINT / MINDOUBLE / MAXDOUBLE or whatever: cos( rand() ); // The cosine will return a number in range of -1 and 1.
In case your rand() function returns values between 0.0 and 1.0: r = rand();
if( rand() % 2 == 0 ) // Switch sign randomly
r = -r;
Note:
It's not a real big problem that the cosine is deterministic due to the fact that random isn't really perfect, too. Hence this is pseudo random number generation.