code: def randomizeSequence(sequence, symbolsPerSequence, numColumns, sparsity, p = 0.25):
    
    randomizedSequence = []
    sparseCols = int(numColumns * sparsity)
    numSymbolsToChange = int(symbolsPerSequence * p)
    symIndices = np.random.permutation(np.arange(symbolsPerSequence))  
    for symbol in range(symbolsPerSequence):
      randomizedSequence.append(sequence[symbol])
    i = 0
    while numSymbolsToChange > 0:
      randomizedSequence[symIndices[i]] = generateRandomSymbol(numColumns, sparseCols)
      i += 1
      numSymbolsToChange -= 1
    return randomizedSequence
docs: Takes a sequence as input and randomizes a percentage p of it by choosing
    SDRs at random while preserving the remaining invariant.
    
    @param sequence (array) sequence to be randomized
    @param symbolsPerSequence (int) number of symbols per sequence
    @param numColumns (int) number of columns in the TM
    @param sparsity (float) percentage of sparsity
    @p (float) percentage of symbols to be replaced  
    @return randomizedSequence (array) sequence that contains p percentage of new SDRs