function [nos ir output esn] = stm()
%stm Testing script
%  Detailed explanation goes here


nTestSeqLength = 2400;
nSeqLength = 1500;
%output = sin((1:nSeqLength) / 4) / 2;
%output = output ;

output = melodyGenerator(1:nSeqLength);
%output = sineGenerator(1:nSeqLength, 500, 20) / 2;
%output = modulatedSineGenerator(1:nSeqLength, 500, 13, 21) / 2;


%output = output - 0.3;

teacher = output(1:nSeqLength);

esn = create_esn(400, 1, 1.25, 0.908);

esn = scaling(esn, 2.0);


figure(1);
plot(teacher(1:1000));

%figure(1);
%plot(1:50, ir(1:5, 1:50));

% train network
[nos ir esn] = train(teacher, esn);
figure(2);
%plot(1:length(teacher), ir(1:10, 1:length(teacher)));
interval = 1:200;

subplot(2, 3, 1);
plot(ir(1, interval));
subplot(2, 3, 2);
plot(ir(2, interval));
subplot(2, 3, 3);
plot(ir(3, interval));
subplot(2, 3, 4);
plot(ir(4, interval));
subplot(2, 3, 5);
plot(ir(5, interval));
subplot(2, 3, 6);
plot(ir(6, interval));
% test run


[nos2 ir esn] = runFNetwork(teacher(1:500), nTestSeqLength, esn);
figure(3);
%wholeSeqLength = nSeqLength + nTestSeqLength;
out = nos2(1:nSeqLength);
plot([out' teacher']); %1:wholeSeqLength, 

% 
% [nos ir error_train esn] = getMSEtrain(1500, teacher, 300, esn);
% [nos ir error_test esn] = getMSEtest(1500, teacher, 300, esn);
% 
% error_train
% error_test



%starting from another random state
%esn.x = rand(1, size(esn.x))' - 0.5;
%[nos ir esn] = runNetwork(100, esn);

%figure(2);
%plot(1:100, nos(1:100));


%plot(1:nSeqLength, output);

%[nos ir esn] = processInput(nSeqLength, esn);
%[nos ir esn] = train(output(1:300), esn);
%plot(1:nSeqLength - 50, nos);


%[nos2 ir esn] = processInput(200, esn);
%plot(1:nSeqLength + 150, [nos nos2]);




