I do not expect a measurable speed difference in the rms implementations I have seen here.
I could be wrong, of course. Thanks, -- Raul On Mon, Nov 18, 2013 at 2:06 AM, Don Kelly <[email protected]> wrote: > You sent an answer to my question before I asked it! Thanks- I suspected > but didn't know that this was it. > > I think that I will stay with the earlier definition: > > rms=:[:%:[:(+/%#)*: > which, while it does have brackets is somewhat more readable for my present > state of understanding. Yours is shorter and I expect it would be faster. > Now all of you have given me enough to digest for now. > Don > > > On 17/11/2013 7:23 AM, Raul Miller wrote: >> >> Here's another definition of rms >> >> Rms=: +/@:*: %:@% # >> Rms 1 2 1 2 >> 1.58114 >> >> Explanation: >> >> We do not need to square the numbers in the argument to #, we only >> need to square them in the argument to +/ >> >> We only need the square root on the result of % >> >> Makes sense? >> >> Also, here's a partial explanation for the (+/%#)&.:*: definition of RMS >> >> &.: means "under" much like &. except that the derived verb has >> infinite rank - the verb on the left gets the entire array which >> resulted from the verb on the right, regardless of the rank of the >> verb on the right. In other words, it is equivalent to (+/ % #) &. >> (*:"_) In other words: square the numbers, add them up, divide by >> their sum, then do the inverse of squaring on the result. >> >> Thanks, >> > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
