generate matrix and occurrence_per_period