Given the discussion in the comments, this comes down to finding a random point on a circle. For instance, if we find a point (x,y) at random within a circle of radius 1, then the vector (.05*x, .05*y, 1) will be a roughly-random vector within the cone of angle arctan(.05) (or approximately 2.9 degrees) about the z axis.
There are several different methods of finding a random point on a sphere, but the most straightforward by far is what's known as the rejection method : find a point at random within the square of radius 1 and then reject it (that is, find another random point) if that point is outside the unit circle. Assuming that rand() returns a random number between 0 and 1.0, then the pseudocode for doing this would look something like:
x = 2.0*rand()-1.0;
y = 2.0*rand()-1.0;
} while ( x*x+y*y > 1.0 );
// (x,y) is now randomly distributed within the unit circle
Since the area of the square is 4 and the area of the circle is π, the probability that the point will be inside the circle is π/4 and the average number of times you'll execute the do loop is 4/π, or approximately 1.27 times for each random point within the circle; there's a less than 1% chance that you'll need more than 3 iterations of the loop to find a point within the circle. This uniform point in the circle can then be translated into a nearly-uniform vector in a spread about the z-axis by means of the method I listed above; in particular, if the maximum angle from the z axis is theta (so the cone's width is 2*theta), then pseudocode for using the random point would look something like:
r = tan(theta);
Vector v(r*x, r*y, 1);
Note that this won't give a precisely uniform angular spread, because the surface of a sphere isn't flat - points near the center of the cone will be generated slightly less often than they 'should' be, compared to points at the fringes. But for small angles theta this gives a pretty good approximation, and it should certainly be good enough for most random-animation purposes.