Python TypeError: 'float' object is not iterable

求大佬帮帮忙 我将x=的这行从x = np.random.random(nums),因为要求随机数是从(-1到1)所以换成了现在这样,然后它就报错了( TypeError: 'float' object is not iterable),请问怎么解决,跪谢!!!!!

nr = np.array([0.0008,0.0001,0.0005,-0.0009,-0.0003])
nS = pd.DataFrame({'P1':[0.0004,0,0,0,0],\
                  'P2':[0,0.0002,0,0.0002,0.0001],\
                  'P3':[0,0,0.0002,0.0001,0.0001],\
                  'P4':[0,0.0002,0.0001,0.0006,0.0001],\
                  'P5':[0,0.0001,0.0001,0.0001,0.0002]})
vline = []
hline = []


for i in np.arange(1000):
    x = (1-(-1)) * np.random.random() + (-1)
    weights = x/sum(x)
    vline.append(np.sum(weights*nr))
    hline.append(np.sqrt(np.dot(weights,np.dot(nS,weights.T))))
plt.scatter(hline,vline)  

img


是16行爆的错,是因为float对象不能调用