How to find the matlab interp1 computational complexity?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kalasagarreddi Kottakota
le 26 Oct 2023
Modifié(e) : Kalasagarreddi Kottakota
le 2 Nov 2023
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 commentaire
Bruno Luong
le 26 Oct 2023
"Are these correct?"
No, O(n^3) is completely off (over estimated), see my answer. Also you don't tell what n is.
Réponse acceptée
Bruno Luong
le 26 Oct 2023
Modifié(e) : Bruno Luong
le 26 Oct 2023
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 commentaires
Bruno Luong
le 31 Oct 2023
Modifié(e) : Bruno Luong
le 31 Oct 2023
doesn't matter for O notation, since log 10, log 2 theirs inverse are constants
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!