Patent ID: 8482978

Claim:
A method for data storage, comprising: storing data in a group of analog memory cells by writing into the memory cells in the group respective storage values, which program each of the analog memory cells to a respective programming state selected from a predefined set of programming states, including at least first and second programming states, which are applied respectively to first and second subsets of the memory cells, whereby the storage values held in the memory cells in the first and second subsets are distributed in accordance with respective first and second distributions; estimating a first median of the first distribution; calculating a read threshold, which differentiates between the first and second programming states, based on the estimated first median; and retrieving the data from the analog memory cells in the group by reading the storage values using the calculated read threshold, wherein the storage values corresponding to the first programming state lie in a given interval and wherein estimating the first median includes: reading at least some of the storage values using one or more intermediate read thresholds, which are positioned inside of the given interval; counting the storage values falling on a given side of each of the intermediate read thresholds; and wherein assessing the first median comprises computing the first median based on the counted storage values.