math.functions: add logit function and a test.

sigmoid is known as expit in scipy
windows-drag
Doug Coleman 2019-02-24 11:04:27 -06:00
parent d70148e365
commit 3f0ff53369
2 changed files with 5 additions and 0 deletions

View File

@ -268,6 +268,7 @@ CONSTANT: log10-factorial-1000 0x1.40f3593ed6f8ep11
{ t } [ 3 15 roots [ 15 ^ 3 .01 ~ ] all? ] unit-test
{ .5 } [ 0 sigmoid ] unit-test
{ t } [ 0 [ sigmoid logit ] keep .000001 ~ ] unit-test
{ 1 } [ 12 signum ] unit-test
{ -1 } [ -5.0 signum ] unit-test

View File

@ -434,8 +434,12 @@ M: float round-to-odd [ (round-to-odd?) ] (float-round) ;
[ recip 2pi * 0 swap complex boa e^ ]
[ <iota> [ ^ * ] 2with map ] tri ;
! expit
: sigmoid ( x -- y ) neg e^ 1 + recip ; inline
: logit ( x -- y ) [ ] [ 1 swap - ] bi /f log ; inline
GENERIC: signum ( x -- y )
M: real signum sgn ;