Vocabulary/ampdotco

From J Wiki
Jump to: navigation, search

>> <<   Back to: Vocabulary Thru to: Dictionary

[x] u&.:v y Under Conjunction

Rank Infinity -- operates on [x and] y as a whole -- WHY IS THIS IMPORTANT?



Executes v on the argument(s); then executes u on the result(s) of v; then executes  v^:_1 (i.e. the obverse of v) on the result of u, giving the end result.

In mathematical terms:

  • Verb v defines a transformation of the argument(s) (x and) y taken as a whole into the v-domain
  • Next, verb u operates on the transformed argument(s)
  • Lastly the result is transformed back from the v-domain to the original domain.

We say that u is applied under v.

Example: Addition (+) applied under logarithm (^.) gives multiplication

   u =: +
   v =: ^.
   3 4  u&.:v  5 1
15 4

Under (Dual) (&.) happens to give the same answer as (&.:) here. But only because (+) and (^.) both have rank 0, which ensures (say) that  3 4 ^. 5 1 is the same as  (3 ^. 5) , (4 ^. 1)

   3 4  u&.v  5 1
15 4

Common Uses

1. Compute the Geometric Mean as: the Arithmetic Mean taken in the "log-domain"

   y =: 2 4 8 16

   mean =: +/ % #         NB. The Arithmetic Mean of y
   mean y
7.5

   ^ mean ^. y            NB. The Geometric Mean: log (^.), then arithmetic mean, then antilog (^)
5.65685
   mean&.:^. y            NB. ditto, but done using (&.:)  NOTE: (&.) DOES NOT WORK
5.65685

Note: Under (Dual) (&.) does not give the same answer as (&.:)

   mean&.:^. y
5.65685
   mean&.^. y
2 4 8 16

Contrast this with the above Example of addition under logarithm.

This is because mean does not have rank 0, it has rank Infinity

   mean b.0
_ _ _
   (mean&.^.) b.0
0 0 0

See below: More Information (1.)

2. Compute standard deviation as the root-mean-square of a list of differences from the mean value

   y =: 0 _3 1 2          NB. list of differences from the mean value

   u =: mean =: +/ % #    NB. mean value of y
   v =: *:                NB. square of y
   stddev =: u&.:v        NB. square root of mean of sum of squares of y
   stddev 0 _3 1 2
1.87083

Related Primitives

Under (Dual) (&.)


More Information

1. Under (Dual) (&.) differs from Under (&.:) in that  u&.v applies u under v cell-by-cell, whereas  u&.:v applies u under v to the entire argument(s) (x and) y . Template:Admon/caution

2.  [x] u&.:v y is the same as

  • v^:_1 [x] u&:v y
  • [x] v^:_1 @: (u&:v) y
  • v^:_1 [(v x)] u (v y)

3.  u&.:v y is the same as

  • v^:_1 u v y
  • v^:_1 @: u @: v y
  • ([: v^:_1 [: u v) y

4.  x u&.:v y is the same as

  • v^:_1 (v x) u (v y)
  • x v^:_1 @: u &: v y
  • x ([: v^:_1 v@[ u v@]) y