Added random number generation and correct formulas for tables