How to find the matlab interp1 computational complexity?
조회 수: 6 (최근 30일)
이전 댓글 표시
Kalasagarreddi Kottakota
2023년 10월 26일
편집: Kalasagarreddi Kottakota
2023년 11월 2일
Hi,
I am trying find the computational complexity of interp1 with 'linear', and "cubic". Can I get some help regarding this?
I am thinking it is O(n) and O(n^3). Are these correct?
댓글 수: 1
Bruno Luong
2023년 10월 26일
"Are these correct?"
No, O(n^3) is completely off (over estimated), see my answer. Also you don't tell what n is.
채택된 답변
Bruno Luong
2023년 10월 26일
편집: Bruno Luong
2023년 10월 26일
If N is the number of data points (x, y), M is the query points (xq)
interp1(x, y, xq, ...)
has complexity of O(M*log(N)) for all methods, if x is sorted.
Essentially it is the time of query where xq are located in subintervals. Time of interpolation value are constant per point even for spline method.
If x is not sorted then you need to add log(N) of sorting but then the O notation remains the same
댓글 수: 6
Bruno Luong
2023년 10월 31일
편집: Bruno Luong
2023년 10월 31일
doesn't matter for O notation, since log 10, log 2 theirs inverse are constants
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!