mam:30000 punktów danych, znajdź największą zmianę czasu, przez 2 tygodnie
- 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
muszę:
- 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
Pytam:
- which algorithm to employ, considering algorithms are not my specialty
- which data structure to use to keep track of the subtotals
Uwaga:
- an answer in pseudo code would be preferred, "prose" is fine if pressured for time
- an answer in Python would be... splendid :)
Jeśli chcesz, możesz wygenerować "fałszywe" dane i uruchomić proponowany algorytm jako test lub udostępnić rzeczywiste dane.
Tu nie chodzi mi o wydajność, poza tym, że chcę znać najszybszy sposób, aby to zrobić, aby nauczyć się, jak zastosować właściwe rozwiązanie i prawidłowy algorytm.
Myślę, że mogę "udowodnić" poprawność nawet z najprostszym algorytmem iteracyjnym, ponieważ zbiór danych jest niewielki, biorąc pod uwagę dzisiejsze komputery.
Do tej pory "poruszam się i przenoszę 14 wektorów z 14 pomiarów", jeśli mógłbyś nauczyć mnie, jak robić to stopniowo z subsumami, byłoby to naprawdę docenione.
Czy jest to przesuwne dwutygodniowe okno lub czy to jest ustalone dwa tygodnie? – sarnold
To jest O (n), jeśli po prostu patrzysz na 14 wartości za każdym razem.Wewnętrzna pętla wykonuje 420 000 razy. O ile nie ma tu czegoś więcej, to nie jest tak wielka sprawa. –
Czy może być kiedykolwiek więcej niż jedna próbka dziennie, czy też ustalono, że każdy znacznik czasu będzie pochodził z innego dnia? – steveha