In some ancient articles, they may tell you the average fo sum of square is (+/%#)@*:
They are correct for some very old versions of J (at least for the old J7 in 1993), becuase at that time rank of monad *: is _, but later it was changed to rank 0. Пн, 18 ноя 2013, Don Kelly писал(а): > The problem is that > > rms =: %:@(+/%#)@*: > > doesn't work in this case but replacing @ with @: does work > (+/%#)@:*: 1 2 1 2 > 1 4 1 4 > (+/%#)@:*: 1 2 1 2 > 2.5 > > it appears that (+/%#)@ 1 2 1 2 leads to 1 4 1 4 -the summation taken over > individual elements > (i.e (+/1%1),(+/4%1)... rather than acting on the whole result of the > squaring (1+4+1+4)%4 (or mean square). > It's the same thing that happens with &. and &.: the &.: and @: have > infinite rank > See At in the dictionary -this is made clear there (why not elsewhere? where > I had problems ). > Thanks to Raul, I see what is going on. > > As a known example: > s=. 1 o. 1p1*0.01*i.100 > rms =: %:@:(+/%#)@:*: > rms s > 0.707107 > %%:2 rms value of a sine wave of magnitude 1 > 0.707107 > > Don > > On 18/11/2013 3:53 AM, Piet de Jong wrote: > >I always read/interpret "@" or "@:" as "of the" > >Took me a while to get this "interpretation" but now I use it all the time > >when I write J programs: > > > > NB. square root "of the" mean "of the" squares. > > > > > >On Mon, Nov 18, 2013 at 6:06 PM, 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 -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
