Sunday, May 8, 2011

Sample Octave code for testing nonmonotonicity


target = [0 0.3 1 0.3 0]';
inputs = [0 0.1 0.3 0.5 1]';
outputs = zeros(5,1);
ic = tinkercell.tc_getInitialValues(tinkercell.tc_allItems());
k = tinkercell.tc_getRowIndex(ic, "INPUT");
for i = 1:5
    x = inputs(i);
    tinkercell.tc_setMatrixValue(ic, k, 0, x);
    tinkercell.tc_updateParameters(ic);
    ss = tinkercell.tc_getSteadyState();
    j = tinkercell.tc_getRowIndex(ss, "OUTPUT");
    if (j > -1)
        outputs(i) = tinkercell.tc_getMatrixValue(ss, j, 0);
    end
end
m = [ inputs outputs ];
m2 = toTC(m);
tinkercell.tc_plot(m2, "input-output");
score = corrcoef( target, outputs )

No comments: