tôi có:30.000 điểm dữ liệu, tìm sự thay đổi lớn nhất thời gian hơn 2 tuần
- 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
tôi cần:
- 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
Tôi hỏi:
- which algorithm to employ, considering algorithms are not my specialty
- which data structure to use to keep track of the subtotals
Lưu ý:
- an answer in pseudo code would be preferred, "prose" is fine if pressured for time
- an answer in Python would be... splendid :)
Nếu bạn muốn, bạn có thể tạo dữ liệu "giả" và chạy thuật toán được đề xuất làm thử nghiệm hoặc tôi có thể chia sẻ dữ liệu thực tế.
Tôi không quan tâm đến hiệu suất ở đây ngoài việc muốn biết cách nhanh nhất để làm điều này để tìm hiểu cách áp dụng giải pháp đúng và thuật toán chính xác.
Tôi nghĩ rằng tôi có thể "chứng minh" tính chính xác ngay cả với thuật toán lặp lại đơn giản nhất vì tập dữ liệu nhỏ cho các máy tính ngày nay.
Cho đến nay, tôi đang "đi ngang và mang theo 14 vectơ 14 phép đo", nếu bạn có thể dạy tôi cách làm điều này từng bước với các khoản phụ, điều đó sẽ thực sự được đánh giá cao.
Đây có phải là cửa sổ trượt hai tuần hay không nó là một hai tuần cố định? – sarnold
Đây là O (n) nếu bạn chỉ cần xem xét 14 giá trị mỗi lần.Vòng lặp bên trong thực hiện 420.000 lần. Trừ khi có điều gì đó đang diễn ra ở đây thì đó không phải là một vấn đề lớn. –
Có bao giờ có thể có nhiều hơn một mẫu mỗi ngày hay cố định rằng mỗi dấu thời gian sẽ là một ngày khác? – steveha