initial writing: 2003-05-01|
last updated: 2004-10-26
If the verbs f0 , ... , fn are atomic, the monads f0`...`fn@.v"0 (and f0`...`fn@.v if v is rank 0) are now implemented by special code, resulting in time/space savings.
A verb f is atomic if f = f"0 , and the shape of the result of f is the shape of one of its arguments or the result of f is an atom. Many primitive verbs are atomic: + - * % ^ ^. etc. Constant verbs with rank 0 results are atomic. If f , g , and h are atomic then so are their compositions f&g f&:g (f g) (f g h) ([: f g) etc; and moreover if a is an atom then a&f and f&a are atomic. Finally, m H. n and x&p. where x is an atom or a list, are atomic.The following example of the normal N(0,1) cumulative distribution function is by J.E.H Shaw of the University of Warwick.
NB.* n01pdf v probability density function for N(0,1) NB.* erf v error function NB.* n01cdfh v cumulative distribution function for N(0,1) using H. NB.* n01cdfr v ratio used for CDF in tails of N(0,1) NB.* n01cdfn v more accurate than n01cdfh in lower tail (say y. < _6) NB.* n01cdfp v more accurate than n01cdfh in upper tail (say y. > 6) NB.* n01cdf v N(0,1) cdf n01pdf =: ([: ^ _0.5"_ * *:) % (%: 2p1)"_ erf =: (*&(%:4p_1) % ^@:*:) * [: 1 H. 1.5 *: n01cdfh=: [: -: 1: + [: erf %&(%:2) n01cdfr=: n01pdf % ] + 1: % ] + 2: % ] + 3: % ] + 4: % ] + 4.5&% n01cdfn=: [: - n01cdfr n01cdfp=: 1: - n01cdfr n01cdf =: n01cdfn`n01cdfh`n01cdfp @. (>&_6 + >&6) " 0 ts=: 6!:2 , 7!:2@] NB. time and space x=: _10 + 0.01 * ?. 10 10 100 $ 1000 ts 'n01cdf x' NB. J 5.02 0.0665599 1.46003e6 ts 'n01cdf x' NB. J 5.01 0.672347 1.2306e7