识别排序列表中的巨大差异

本文关键字:巨大 排序 列表 识别 | 更新日期: 2023-09-27 18:33:20

假设我有一个双打列表:

0.0015
0.0016
0.0017
0.0019
0.0021
0.0022
0.0029
0.0030
0.0033
0.0036

与其他值相比,0.0022 和 0.0029 显然有很大的差异,但是有没有办法让我的 C# 程序能够在排序列表中注意到这种差异 W/O 使用静态阈值。因为我收到的这些数据,差异可能并不总是 0.0007 的差异。因此,我希望我的程序能够足够"智能"来识别这些"大"差异并将此列表分成多个列表。

识别排序列表中的巨大差异

如果我正确理解了你的问题,那就去吧。 您可能需要填补一些空白,但以下示例将出现漂移:

List<double> doubleList = new List<double>{
    0.0015,
    0.0016,
    0.0017,
    0.0019,
    0.0021,
    0.0022,
    0.0029,
    0.0030,
    0.0033,
    0.0036
};
double averageDistance = 0.0;
double totals = 0.0;
double distance = 0.0;
for (int x = 0; x < (doubleList.Count - 1); x++)
{
    distance = doubleList[x] - doubleList[x + 1];
    totals += Math.Abs(distance);
}
averageDistance = totals / doubleList.Count;
// check to see if any distance between numbers is more than the average in the list
for (int x = 0; x < (doubleList.Count - 1); x++)
{
    distance = doubleList[x] - doubleList[x + 1];
    if (distance > averageDistance)
    {
        // this is where you have a gap that you want to do some split (etc)
    }
}

计算平均平均值 (http://en.wikipedia.org/wiki/Arithmetic_mean) 和标准差 (http://en.wikipedia.org/wiki/Standard_deviation)。 使用它们来确定超出"n"个标准差的值。

另一种方法是计算连续值之间的所有差异,对这些差异进行排序(降序),并假设这些差异值中的前"m"%表示最大的变化。