3

可以说我有一个双打列表:

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 差异。因此,如果我的程序能够“智能”到足以识别这些“大”差异并将这个列表分成多个列表,我会更喜欢。

4

2 回答 2

3

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

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)
    }
}
于 2013-10-01T02:17:26.543 回答
1

计算平均值(http://en.wikipedia.org/wiki/Arithmetic_mean)和标准差(http://en.wikipedia.org/wiki/Standard_deviation)。使用这些来确定落在“n”个标准偏差之外的值。

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

于 2013-10-01T03:02:17.717 回答