fix bug on distibution_matrix.py, update R scripts