add generate matrix according to density and range