Index: /applications/robust/main.cpp
===================================================================
--- /applications/robust/main.cpp (revision 1336)
+++ /applications/robust/main.cpp (revision 1337)
@@ -7,11 +7,13 @@
  */
 
+#include "estim/arx.h"
 #include "robustlib.h"
 #include <vector>
 #include <iostream>
 #include <fstream>
+#include <itpp/signal/poly.h>
 
 using namespace itpp;
-//using namespace bdm;
+using namespace bdm;
 
 const int emlig_size = 2;
@@ -20,4 +22,6 @@
 int main ( int argc, char* argv[] ) {
 	
+	itpp::Laplace_RNG LapRNG = Laplace_RNG();
+
 	/*
 	// EXPERIMENT: 100 AR model generated time series of length of 30 from y_t=0.95*y_(t-1)+0.05*y_(t-2)+0.2*e_t, 
@@ -134,9 +138,13 @@
 	vector<vector<string>> strings;
 
-	char* file_strings[3] = {"c:\\ar_student_single.txt", "c:\\ar_student_single.txt","c:\\ar_cauchy_single.txt"};
+	char* file_strings[3] = {"c:\\dataADClosePercDiff", "c:\\ar_student_single","c:\\ar_cauchy_single"};
 
 	for(int i = 0;i<3;i++)
 	{			
-		ifstream myfile(file_strings[i]);
+		char dfstring[80];
+		strcpy(dfstring,file_strings[i]);
+		strcat(dfstring,".txt");
+		
+		ifstream myfile(dfstring);
 		if (myfile.is_open())
 		{			
@@ -162,5 +170,13 @@
 		vector<vec> conditions;
 		//emlig* emliga = new emlig(2);
-		RARX* my_rarx = new RARX(3,20,true);
+		RARX* my_rarx = new RARX(2,30,false);
+		
+		/*
+		mat V0 = 0.0001 * eye ( 3 );
+		ARX* my_arx = new ARX(0.97);
+		my_arx->set_statistics ( 1, V0 ); //nu is default (set to have finite moments)
+		my_arx->set_constant ( false );
+		my_arx->validate();
+		*/
 
 		for(int k = 1;k<170;k++)
@@ -186,8 +202,12 @@
 
 				my_rarx->bayes(conditions[k-3]);
-
-					
 				
-				if(k>10)
+				vec cond_vec;
+				cond_vec.ins(0,conditions[k-3][0]);
+				
+				// my_arx->bayes(cond_vec,conditions[k-3].right(2));
+					
+				
+				if(k>5)
 				{
 					//my_rarx->posterior->step_me(0);
@@ -195,12 +215,52 @@
 					mat samples = my_rarx->posterior->sample_mat(50);
 					
+					vec sample_prediction;
+					for(int t = 0;t<50;t++)
+					{
+						vec lap_sample = conditions[k-3].left(2);
+						
+						lap_sample.ins(0,LapRNG());
+
+						sample_prediction.ins(0,lap_sample*samples.get_col(t));
+					}
+
+					vec sample_pow = sample_prediction;
+					vec poly_coefs;
+					bool stop_iteration = false;
+					int en = 0;
+					do
+					{
+						double poly_coef = ones(sample_pow.size())*sample_pow/sample_pow.size();
+
+						if(abs(poly_coef)>numeric_limits<double>::epsilon())
+						{
+							sample_pow = elem_mult(sample_pow,sample_prediction);
+							poly_coefs.ins(poly_coefs.size(),pow(-1,en)*poly_coef);
+						}
+						else
+						{
+							stop_iteration = true;
+						}
+						
+						en++;
+					}
+					while(!stop_iteration);
+
+					cvec action = 
+					
 					
 					cout << "MaxLik coords:" << my_rarx->posterior->minimal_vertex->get_coordinates() << endl;
 
-					for(int s = 0;s<samples.rows();s++)
-					{
-						
-						double avg_parameter = samples.get_row(s)*ones(samples.cols())/samples.cols();						
-						
+					double prediction = 0;
+					for(int s = 1;s<samples.rows();s++)
+					{
+						
+						double avg_parameter = samples.get_row(s)*ones(samples.cols())/samples.cols();
+
+						prediction += avg_parameter*conditions[k-3][s-1];
+
+						
+						
+						/*
 						ofstream myfile;
 						char fstring[80];
@@ -227,5 +287,52 @@
 						}
 						myfile.close();
-					}
+						*/
+					}
+
+					/*
+					enorm<ldmat>* pred_mat = my_arx->epredictor(conditions[k-3].left(2));
+					double prediction2 = pred_mat->mean()[0];
+					*/
+
+					ofstream myfile;
+					char fstring[80];
+					//char f2string[80];
+					strcpy(fstring,file_strings[j]);
+					//strcpy(f2string,fstring);
+
+					strcat(fstring,"pred.txt");
+					//strcat(f2string,"2pred.txt");
+					
+
+					myfile.open(fstring,ios::app);
+					
+					//myfile << my_rarx->posterior->minimal_vertex->get_coordinates()[0];
+					myfile << prediction;
+					
+					if(k!=strings[j].size()-1)
+					{
+						myfile << ",";
+					}
+					else
+					{
+						myfile << endl;
+					}
+					myfile.close();
+
+					/*
+					myfile.open(f2string,ios::app);
+					myfile << prediction2;
+					
+					if(k!=strings[j].size()-1)
+					{
+						myfile << ",";
+					}
+					else
+					{
+						myfile << endl;
+					}
+					myfile.close();
+					*/
+
 				}					
 			}	
@@ -246,5 +353,13 @@
 			cout << "Step: " << i << endl;*/
 		}
+
+
 	}
+
+
+	// EXPERIMENT: One step ahead price prediction. Comparison of classical and robust model using optimal trading
+    //             with maximization of logarithm of one-step ahead wealth.
+
+	
 		
 		/*
Index: /applications/robust/robustlib.h
===================================================================
--- /applications/robust/robustlib.h (revision 1336)
+++ /applications/robust/robustlib.h (revision 1337)
@@ -10,4 +10,5 @@
 #include <stat/exp_family.h>
 #include <itpp/itbase.h>
+#include <itpp/base/random.h>
 #include <map>
 #include <limits>
@@ -30,5 +31,4 @@
 class vertex;
 class emlig;
-
 
 /*
@@ -2402,7 +2402,4 @@
 		
 	}
-
-
-	
 	
 };
