summaryrefslogtreecommitdiffstats
path: root/test/ulcer_index.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/ulcer_index.c')
-rw-r--r--test/ulcer_index.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ulcer_index.c b/test/ulcer_index.c
new file mode 100644
index 0000000..f856723
--- /dev/null
+++ b/test/ulcer_index.c
@@ -0,0 +1,28 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_ulcer_index( void )
+{
+ fp_t const x[] = { 10, 12, 11, 13, 12, 14, 11, 13, 12, 15 };
+ fp_t const * const inp[1] = { x };
+
+ /* k=3, cumulative HHV (running max from index 0) */
+ /* HHV: 10, 12, 12, 13, 13, 14, 14, 14, 14, 15 */
+ /* d%: 0, 0, 8.333, 0, 7.692, 0, 21.429, 7.143, 14.286, 0 */
+ /* d^2: 0, 0, 69.444, 0, 59.172, 0, 459.184, 51.020, 204.082, 0 */
+ /* SMA3 of d^2, then sqrt: */
+ /* i=2: window [0,1,2], d^2=[0,0,69.444], mean=23.148, UI=4.811 */
+ /* i=3: window [1,2,3], d^2=[0,69.444,0], mean=23.148, UI=4.811 */
+ /* i=4: window [2,3,4], d^2=[69.444,0,59.172], mean=42.872, UI=6.548 */
+ /* i=5: window [3,4,5], d^2=[0,59.172,0], mean=19.724, UI=4.441 */
+ /* i=6: window [4,5,6], d^2=[59.172,0,459.184], mean=172.785, UI=13.145 */
+ /* i=7: window [5,6,7], d^2=[0,459.184,51.020], mean=170.069, UI=13.041 */
+ /* i=8: window [6,7,8], d^2=[459.184,51.020,204.082], mean=238.095, UI=15.430 */
+ /* i=9: window [7,8,9], d^2=[51.020,204.082,0], mean=85.034, UI=9.221 */
+ fp_t const e[] = { 4.811252, 4.811252, 6.547672, 4.441156, 13.144774, 13.041013, 15.430335, 9.221389 };
+ fp_t const * const exp[1] = { e };
+
+ uint_t k = 3;
+ return ts_test(ts_ulcer_index, ts_ulcer_index_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&k, &ts_ulcer_index_p);
+}