#include #include #include "ts.h" bool ts_test_fisher_transform( void ) { /* k=3, prices increasing monotonically */ fp_t const o[] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; fp_t const h[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 }; fp_t const l[] = { 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 }; fp_t const c[] = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; fp_t const * const x[] = { o, h, l, c }; /* Window indices [1..3], H=[13,14,15], L=[10,11,12], range=5, val=(14-10)/5=0.8 */ /* fisher = 0.5*ln(0.8/0.2) + 0.5*0 = 0.5*ln(4) = 0.69315 */ /* Next: H=[14,15,16], L=[11,12,13], val=(15-11)/5=0.8, fisher=0.5*ln(4)+0.5*0.69315=0.69315+0.34657=1.03972 */ /* Monotonic, so all val=0.8, fisher converges toward ln(4) = 1.38629 */ /* f1=0.69315, f2=1.03972, f3=1.21301, f4=1.29965, f5=1.34297, f6=1.36463, f7=1.37546 */ fp_t const ef[] = { 0.69315, 1.03972, 1.21301, 1.29965, 1.34297, 1.36463, 1.37546, 1.38088, 0, 0 }; fp_t const et[] = { 0, 0.69315, 1.03972, 1.21301, 1.29965, 1.34297, 1.36463, 1.37546, 0, 0 }; fp_t const * const exp[2] = { ef, et }; uint_t k = 3; return ts_test(ts_fisher_transform, ts_fisher_transform_offset, x, exp, sizeof( o ) / sizeof( *o ), (ts_constant_t *)&k, &ts_fisher_transform_p); }