我有:
- 30,000 data points
- each data point is a measurement of type float
- each measurement is associated with a date
- each date has only one measurement
- no dates are without measurements
- the data comes in the form of a text file: 30,000 lines in this form:
- YYYY-MM-DD I,F (e.g. 1977-02-08 20.74)
- measurement appearing in the source file are already sorted by date
我需要:
- a time-interval T with boundaries (s,e) /* start, end */
- (s - e = 14 days) the time-interval *must* be 2 weeks
- define min as the lowest value in the interval T
- define max as the greatest value in the interval T
- the chosen T needs to have the greatest distance btwn max and min of all possible Ts
- break ties among intervals T by choosing the most recent (with the greatest s value)
- the chosen T must consider all jumps in the 14 days, not just the values @ s and e
- if the overall "variance" in the interval is great but the jump
|max-min| is not the greatest in absolute value, T is not the right choice,
even if it's an "exciting" interval
我在问:
- which algorithm to employ, considering algorithms are not my specialty
- which data structure to use to keep track of the subtotals
笔记:
- an answer in pseudo code would be preferred, "prose" is fine if pressured for time
- an answer in Python would be... splendid :)
如果需要,您可以生成“虚拟”数据并运行您提出的算法作为测试,或者我可以共享实际数据。
除了想知道最快的方法来学习如何应用正确的解决方案和正确的算法之外,我在这里不太关心性能。
我认为即使是最简单的迭代算法我也可以“证明”正确性,因为考虑到当今的计算机,数据集很小。
到目前为止,我正在“遍历并携带 14 个测量值的 14 个向量”,如果您能教我如何使用子和逐步执行此操作,那将非常感激。