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


nSeqLength = 1200;
%output = sin((1:nSeqLength) / 4) / 10;
%output = output ;

[input output] = generate_freqGen_sequence(nSeqLength, 14, 26, 200);  %14, 26, 200);

output = 2 * output - 1;
output = output / 2;
%output = output .^2;
%output = abs(output);

plot (1:nSeqLength, [input output]);


esn = create_esn(1, 200, 1, 20, 0.8);  %1, 200, 1, 20, 0.8);(esn, 0.5, 1, 3.4);  

esn = scaling(esn, 0.5, 1, 3.4);      
                    %(esn, 2.5, 1, 5) (esn, 0.5, 1, 1.4)(esn, 0.15, 1, 1.4); 
plot([input output]);


%max(abs(eig(esn.resWeights)))

%initial run

%[nos ir esn] = runNetwork(100, esn);
%figure(1);
%plot(1:100, nos(1:100));

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

% train network
[nos ir esn] = train(input, output, esn);

figure(2);
%plot(1:length(input), ir(1:5, 1:length(input)));

interval = 400:500;

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

irt = ir';
% test run

% [nos2 ir esn] = runNetwork(input, esn);
% figure(3);
% plot([nos nos2]);

[nos2 ir esn] = runNetwork(input, esn);
%[nos2 ir esn] = runNetwork(input, esn);
figure(4);
plot([nos2' output]);


% compute errors
[nos ir error_train esn] = getMSEtrain(nSeqLength, input, output, 200, esn)
%plot(ones(100)*error);

[nos ir error_test esn] = getMSEtest(nSeqLength, input, output, 200, esn)
figure(5);
plot([nos' output]);

error_train
error_test
error_test
%figure(5);
%plot(1:length(input), ir(1:5,1:length(input)));
%plot([nos2' output]);

% 
% error_train =
% 
%   7.1063e-007
% 
% 
% error_test =
% 
%   7.9812e-004



%generalization
% input = ones(100, 1) / 300;
% [nos2 ir esn] = runNetwork(input, esn);
% input = 1:300;
% input = input / 300 + 0.0;
% [nos2 ir esn] = runNetwork(input', esn);
% figure(6);
% plot(nos2);

%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]);




