A method for storing data in a memory that includes a plurality of analog
memory cells includes mapping the data to programming values, which are
selected from a set of nominal programming values. The set of nominal
programming values includes at least a first nominal programming value
and a second nominal programming value, which is higher than the first
nominal programming value. A part of the data is stored in the analog
memory cells by programming at least a first group of the cells using the
first nominal programming value. A statistical characteristic of the
first group of the cells is measured after programming the first group of
the cells using the first nominal programming value. The second nominal
programming value is modified responsively to the statistical
characteristic, and at least a second group of the cells is programmed
using the modified second nominal programming value.