What is the computacional complexity in asymptotic notation, O(n) , for the function "pdist2" ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Isaac Newton Melo Machado
el 7 de Jun. de 2017
Respondida: Walter Roberson
el 7 de Jun. de 2017
What is the computacional complexity in asymptotic notation, O(n) , for the function "pdist2" ?
0 comentarios
Respuesta aceptada
Walter Roberson
el 7 de Jun. de 2017
With a vector of length L, each pair of values has L subtractions, followed by L squaring (each is one multiplication), followed by L-1 additions, followed by one square root. So far this is independent of the number of entries in the matrix, so for any given L, the time is constant.
The number of pairs of distances is N * (N-1) / 2
Therefore pdist2() is O(N^2)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!