list = [1, 2, 1, 2, 4] matrix = [[3], [2], [3], [2], [9]]
When I use this function to calculate the randomised mode from a normal list it works fine