How to calculate or approximate the median of a list without storing the list

后端 未结 10 1165
你的背包
你的背包 2020-11-28 22:24

I\'m trying to calculate the median of a set of values, but I don\'t want to store all the values as that could blow memory requirements. Is there a way of calculating or ap

10条回答
  •  抹茶落季
    2020-11-28 22:35

    I don't think it is possible to do without having the list in memory. You can obviously approximate with

    • average if you know that the data is symmetrically distributed
    • or calculate a proper median of a small subset of data (that fits in memory) - if you know that your data has the same distribution across the sample (e.g. that the first item has the same distribution as the last one)

提交回复
热议问题