fix small perf regression in rand_mat_stat