JuliaDynamics / RecurrenceAnalysis.jl

Recurrence Quantification Analysis in Julia
https://juliadynamics.github.io/RecurrenceAnalysis.jl/stable/
MIT License
45 stars 12 forks source link

Return Type of rqa() #59

Closed felixcremer closed 5 years ago

felixcremer commented 5 years ago

Why is the return type of rqa a Dict? With a NamedTuple you still have the clear connection between the values and the name of the metric. Furthermore, the return values are ordered, and it is a little bit cheaper because it needs less allocations. See https://discourse.julialang.org/t/namedtuples-vs-dict/13119 I made some tests with NamedTuples, with the code on my branch. For a 100 x 100 RecurrenceMatrix the number of allocations is reduced from 257 to 209 and the running time is reduced from 112,5 microseconds to 107,8 microseconds. For me this is important, because I want to apply rqa on a large number of pixels (at least a million) with around 100 timesteps.

Datseris commented 5 years ago

Thanks for the concern.

Are you willing to open a Pull Request so we can see your code and suggestion, and thus understand it further?

To answer your question, there is no specific reason for the return type to be a dictionary.

Datseris commented 5 years ago

For me this is important, because I want to apply rqa on a large number of pixels (at least a million) with around 100 timesteps.

I just have to warn you that as the trajectory size increases, the dictionary-induced allocations become insignificant (as they are a flat constant). So this shouldn't affect the performance of large matrices in any significant manner, but still it has measurable impact on small matrices (and thus also the @windowed implementation).


EDIT: Sorry, I now understand that you mean that you want to call rqa a million times on Recurrence matrices that are all 100x100. Yes in this case this has measurable impact!