Optimal system identification