Hi I am trying to improve my error function . I have some data that is in form of nested tuple. These tuple nesting is base on importance of the data (all the lowest depth data is in as real numbers). example, (1,(1,1)) and (1,(1,0.5)). To find error between these two tuples, I use simple recursion version of AME function (this function only work on same type of nested tuple structures). $$ Error(X,Y) = 1/n \sum_{i=1}^n |X_i-Y_i| \text{ if } X_i \in R \text{ or } Y_i \in R \text{ else } Error(X_i,Y_i) $$ $$ n= |X| = |Y| $$ Using this Error( (1,(1,1)),(1,(1,0.5)) ) we get 0.125 error . Now my question is can we represent the nested tuple using complex numbers numbers and find the error faster and more efficiently ? $$ 1 + (1 +i)i \text{ and } 1 + (1 +0.5i)i $$
$\begingroup$ $\endgroup$
2 - $\begingroup$ No. Why are you worrying about efficiency while doing 4 arithmetic operations? That’s already efficient. $\endgroup$Eric– Eric2025-08-17 21:30:10 +00:00Commented Aug 17 at 21:30
- 1$\begingroup$ Whether changing the data representation improves performance depends on the way the data structures are implemented. You should only explore this kind of optimization when you know the calculation is an actual bottleneck in your program. $\endgroup$Ethan Bolker– Ethan Bolker2025-08-17 21:30:12 +00:00Commented Aug 17 at 21:30
Add a comment |