Source: https://cs2study.com/wp-content/uploads/2021/03/random-function.pdf