/(/ ==================== / Tools / ==================== / ( .R `matchR ) `text. `r. / Check whether attribute are up to date text. : .R `text. ; r. : .R `r. / Update them if not ! _d / show all objects in dictionary . f5 to insert result in text `r `l `text `ll `I `Undo `acnt `i `v ( .R `dics ) _d / f6 this to show all folders ( .R `diz )[ `y2001 ; `.CoSy.newjob ] / create new job in this dictionary / ( .R `NEWJOB ) `a / a..h : " Arthur Whitney's basic collection " `a "C:/CoSy/K/CoSy/math.txt" 0: text a : r math.a : ( saved .R ) . `math `a ll ( `a . `nor ) 10 ( .R `Jobs ) _d / ======================== / sat.may.20160521 / ======================== / perm: {:[1:'(x,x)#1,x#0)[;0,'1+_f x-1];,!x]} perm 3 perm2: {{x@:'(x,x)#1,x#0)[;0,'1+_f x-1];,!x]} p 3 p:{x'{:$[x=1;,0;,/a,''(&:'~a=\:a:!x)@\:.z.s x-1]}[#x]} / ======================== / fri.may.20160527 / ======================== / p : { ( ,/ @\: )/ ,\ ( , < <: )' x =\: x : ! x } p p 3 / ==================== / / ==================== /)/ / \/ CUBES \/ ------------------------------------- / plot..c : `plot : plot : ( 0 1 ; 0 1 ) plot : ( 1 0 ; 0 1 ) : plot : ( 0 0 1 ; 0 1 1 ) plot : square : plot : , square : 5 #' ( ~ = )\ 2 2 _vs ! _ 2 ^ 2 ncube : { + 2 _vs ! _ 2 ^ x } ncube..h : " vertices of measure ( cube ) of dimension x . i.e. : all the x bit binary numbers " gray : { x ( ~ = )' 0 , -1 _ x } gray..h : " converts binary number to its Gray code which change just 1 bit at a time " hamiltonian : { ( 1 + _ 2 ^ x ) # gray' ncube x } hamiltonian..h : " path visiting each vertex of cube of dimension x " square..d : " , + hamiltonian 2 " square..h : " list containing path around 2 dimensional measure ( cube ) " : plot : square ncube 5 : plot : , square : 5 #' ( ~ = )\ 2 2 _vs ! _ 2 ^ 2 square : 5 #' ( ~ = )\ 2 2 _vs ! _ 2 ^ 2 plot : square : plot : , square : 5 #' ( ~ = )\ 2 2 _vs ! _ 2 ^ 2 : plot : ( 1! 10 ) * ( ! 10 ) + 10 # , square : plot : _ ( 10 * , square ) , ( 1 */: ! 10 ) + 10 # , square `plot plot. / /\ CUBES /\ ------------------------------------- / Simplex - AllConnect / / \/ Quasi pythagorean triples \/ ------------------------ / ( to . 1900 1999 ) / ,\: 1782 : Q : Q ,' { ( -/ x ^ 2 ) ^ % 2 } @' ( Q : to . 1900 1999 ) ,\: 1782 ( ! 99 ) ,' ( :: ; _: ) .'/: Q 1 Q 87 +/ =/ + ( :: ; _: ) .'/: Q 1 r @ & =/ ( :: ; _: )'' r 1 { ( -/ x ^ 2 ) ^ % 2 } @' ( to . 1900 1999 ) ,\: 1782 { ( +/ x ^ 2 ) ^ % 2 } 879 1782 1987 / /\ Quasi pythagorean triples /\ ------------------------ /\ / / \/ FINANCIAL \/ ========================================== \/ / pv:{[c;t;d]+/c*d^t} ; pv[c:.1 .1 1.1;t:1 2 3]d:%1.1 / Arthur's ( pv[c;t]?.97 ; pv[c;;d]?.98 ; pv[;t;d]?.99 ) pv : { +/ y * x ^ # y } ; pv..h : " Present Value of stream y at rate x " pv[ 1 1 1 1 1 ; % 1.1 ] PVyi[ .1 ; -100 55 121 ] / PVyi : { +/ ( ( 1 + x ) ^ - ! # y ) * y } PVyi..h : " Present value of stream y discounted at rate x . From Yuji Ijiri " /(/ WALL ST WORDS /)/ RelStrength : { ( %/ %/' ( x[ 0 20 ] ; y[ 0 20 ] ) - 1 ) RelStrength : { ( %/ %/' ( StockPrice[ 0 20 ] ; IndexPrice[ 0 20 ] ) - 1 ) FirsTrade but proportions / \/ Martingales 080317 \/ ================================== \/ / See email <> Dave , met at MLP : odds : 18 % 37 38 />/ 0.4864865 0.4736842 avg QW : odds[ 1 ] > 1000 _draw 0 />/ 0.462 roul : { odds[ 1 ] > x _draw 0 } ; roul 10 0 0 1 1 0 1 0 1 1 0 { x ; +/ roul 1000 }' 10 # 1 { x ; +/ QW : odds[ 1 ] > 1000 _draw 0 }' 10 # 1 471 483 498 466 484 472 495 464 471 465 avg r />/ 476.9 winf : { kitty +: bet ; loss :: 0.0 ; bet :: 1.0 } lossf : { kitty -: bet ; bet :: kitty & 2 * loss +: bet } trial : { :[ x ; winf _n ; lossf _n ] ; accum ,: , ( x ; kitty ; loss ; bet ) } kitty : 1e2 ; loss : 0.0 ; bet : 1.0 Q : -1 ; accum : , ( kitty ; loss ; bet ) ; do[ # QW ; trial[ QW Q +: 1 ] ] kitty : 1e2 ; loss : 0.0 ; bet : 1.0 accum : , ( .5 ; kitty ; loss ; bet ) ; while[ kitty > 0 ; trial[ * roul 1 ] ] accum tab2html accum delete ` $ VMs "win loss bet lossf winf odds accum trial kitty Kitty roul" / / Martingales 080317 /\ ================================== \/ / / Old CoSy / RLA PV RA | Returns present value of payment stream in RA assuming interest rates in LA | Modified from : Accounting Structured in APL ; YuriIjiri / CMU ; |Amer Acnt Assoc ; 1984 R+/((1+LA)*1-__RA)ÆRA |1993 10 12 13 52, Bob A RLA LvlPay RA | Syntax: PMT  PV Æ PeriodicInterest LvlPay NumberOfPeriods . | Interest expressed as proportion . R(1E"10 ONct ' ''- ( 1 - LA PV RA _ TMPSHOW A ) * 2 '' GSSRCH 0 1 ')[2] |1993 10 14 0 15, Bob A { ( .R . `math `PVyi )[ .065 ; 15 # x ] } ? 84000 />/ 8388.389 lvlPay : { ( .R . `math `PVyi )[ x ] y # z ] } ? y } : { ( .R . `math `PVyi )[ Q ; ( 12 * 15 ) # x ] } ? 80000 />/ 685.1284 OBV : {[ C ; Cp ; V ] +\ C % ( _abs C : C - Cp ) * V % 100 } OBV..h : " On Balance Volume " : Plot : OBV[ ! 20 ; -1 + ! 20 ; 10 ] : .r : 0: "/k/stat_k.txt" / From http://kx.com/a see / `a