Minor fixes in inverse method
Added random function to Math class