added functional version of matrix generator for tomoki prob