Numpy's random.rand() function produces random floats between 0 and 1. How do I transform the output of this function to produce random floats between -1 and 1?
Current output:
In[]: numpy.random.rand(3, 2)
Out[]:
array([[0.13568674, 0.72465483],
[0.48726461, 0.68867378],
[0.50463821, 0.28619853]])
Desired (example) output:
In[]: numpy.random.rand(3, 2)
Out[]:
array([[-0.13568674, 0.72465483],
[-0.48726461, 0.68867378],
[0.50463821, -0.28619853]])
I would not like to use random.uniform().
(numpy.random.rand(3, 2) - 0.5) * 2np.random.uniform? That's an odd restriction; do you have a good reason for avoiding it, and are there other, similar restrictions? You seem be operating under an unusual set of constraints, and it would be useful to know what those are.