Added assertions to check conditions for exiting while loop

in _raisePermanenceToThreshold method

fixes #1322 
Yikes - we can't do this. We need to use the same random generator as used in the C code, i.e. NupicRandom. This is initialized as the member variable _random. Search for that to see how it's used.