Added functions to simulate chain and calculate r