modify the matlab codes for occupancy estimation