It seems like explicit rank is exactly what you want.
On Sat, Apr 19, 2014 at 11:53 PM, Raul Miller <rauldmil...@gmail.com> wrote: > https://en.wikipedia.org/wiki/Logarithmic_mean defines logarithmic > mean as the the limit of difference of two numbers divided by the > difference of their (natural) logs. The limit is to deal with the case > where the two numbers are equal - in this case, we want an identity > function. > > I was tempted to implement logarithmic mean as > Lm=: (- % -&^.)^:~: > > But this has a problem with rank: > 2 Lm 2 > 2 > 2 3 Lm 3 2 > 2.4663 2.4663 > 2.4663 2.4663 > > I could solve this with ("0) but that strikes me as inefficient. > L2=: (- % -&^.)^:~:"0 > > So, instead: > L=: (]*=) + - % -&^. > > ((L-:L2) |.) i.1e5 > 1 > > Is that worth it? > > timespacex '(L |.) i.1e5' > 0.0365999 5.24506e6 > timespacex '(L2 |.) i.1e5' > 0.0828581 3.14982e6 > > Probably... > > A caution, though: > 0 L 0 > |NaN error: L > > Because: > ^. 0 > __ > > So maybe the explicit rank implementation isn't such a bad idea after all? > > Thanks, > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm