Optimal Neural Codes for Control and Estimation