On 5/17/07, kamakura <[EMAIL PROTECTED]> wrote:
Then, is the following syntactics  wrong?

mean"3 u

In this case,
  #$u
3

mean"3 u and mean u are the same.

if mean"1&.|:u is true syntactics.  It seems to give the same result.
When we want to operate user defined function f, is f"1&.|:u correct
rule?

mean"1 means take the median of rank 1 values.

mean"1&.|: means, in essence, use the first dimension for these
rank 1 values, rather than the last.

In other words, the definition of "correct rule" depends on what
you want.

That said,
  (mean -: mean"1&.|:) u
1

...given the definition of mean, this is not an issue.  This is because
mean u is
  (+/ % #) u
which is
  (+/u) % #u
where

  #u
3

and

  +/u
is
  (0{u) + (1{u) + (2{u) + 3{u
or
  +/u
8 15 12 15 15
12  7 13 13 15
14 23 14 22  8
10 24 12 15 14

In other words, you are already adding atoms along the first
dimension, and dividing by the value of that dimension.

It's only for something like median where you get different results:

  (median -: median"1&.|:)u
0

When you look at how median works, this should become obvious:

  midpt u
1

  1 { /:~ u
1 6 0 4 4
1 3 3 6 6
5 7 8 8 2
1 9 7 9 9

(and the rest of median's definition makes no difference in this
case.)

Basically, median is picking the median item and median item
is not what you are looking for.

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to