Added a discretization function in utils.py.