The sum is not exactly equal to 1.0, because of floating point errors, not related to numpy or python. But, you can modify last element to account for that error. Like:
probs = np.random.random(10)
probs = probs / probs.sum()
probs[-1] = 1 - probs[:-1].sum()
probs.sum()
>>>
1.0
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…