#! gamma(x) = integral 0..inf [ t^(x-1) exp(-t) ] dt
#! gamma(n+1) = n! for n > 0
dup Z:(-inf,0]? [
- drop inf
+ drop 1./0.
] [
dup abs gamma-lanczos6 swap dup 0 > [ drop ] [ gamma-neg ] if
] if ;
#! gammaln(x) is an alternative when gamma(x)'s range
#! varies too widely
dup 0 < [
- drop inf
+ drop 1./0.
] [
dup abs gammaln-lanczos6 swap dup 0 > [ drop ] [ gamma-neg ] if
] if ;
: minmax ( seq -- min max )
#! find the min and max of a seq in one pass
- inf -inf rot [ dup pick max -rot nip pick min -rot nip ] each ;
+ 1./0. -1./0. rot [ dup pick max -rot nip pick min -rot nip ] each ;
: absminmax ( seq -- min max )
#! find the absolute values of the min and max of a seq in one pass