1. A method for iteratively writing contents to memory locations, the method comprising: receiving desired contents for a memory location to write through a plurality of write signals, a desired accuracy for the memory location, and conditions on a number of iterations to the memory location; initializing a statistical model associated with the memory location and an iterations counter; performing a write iteration to the memory location, the write iteration comprising: selecting one of the write signals to be applied to the memory location, the selecting responsive to the desired contents, the desired accuracy, the iterations counter, the conditions on the number of iterations, and the statistical model; applying the write signal to the memory location; reading current contents of the memory location; and determining whether to continue with an other write iteration to the memory location or to halt, the determining responsive to the current contents of the memory location, the desired contents, the desired accuracy, the iterations counter and the conditions on the number of iterations; and in response to determining to continue with an other write iteration to the memory location: updating the statistical model based on the desired contents, the desired accuracy, the iterations counter, the current contents of the memory location, and the statistical model; and performing the selecting, the applying, the reading, and the determining.