Index: branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/SBART.cs
===================================================================
--- branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/SBART.cs	(revision 15458)
+++ branches/MathNetNumerics-Exploration-2789/HeuristicLab.Algorithms.DataAnalysis.Experimental/SBART.cs	(revision 15459)
@@ -125,6 +125,4 @@
 
       int n = x.Length;
-      float[] leverage = new float[n];
-      float[] y_smoothed = new float[n];
       int ic = n - 1;
       int ier = -99;
@@ -133,8 +131,8 @@
 
       float crit = -99.0f;
-      int icrit = 0; // 0..don't calc CV,  1 .. GCV, 2 CV
+      int icrit = 1; // 0..don't calc CV,  1 .. GCV, 2 CV
 
       // float smoothingParameter = -99.0f;
-      int smoothingParameterIndicator = 1; 
+      int smoothingParameterIndicator = 0; 
       float lowerSmoothingParameter = 0f;
       float upperSmoothingParameter = 1.0f;
@@ -153,5 +151,31 @@
         SBART.setreg_x64(xs, ys, ws,
           ref n, xw, ref nx, ref min, ref range, knots, ref nk);
-        if(nx < 4) {
+
+        /* use all points as knot points 
+        nk = nx + 2;
+        knots[0] = xs[0];
+        knots[1] = xs[0];
+        knots[2] = xs[0];
+        Array.Copy(xs, 0, knots, 3, nx);
+        knots[nx + 3] = xs[nx - 1];
+        knots[nx + 4] = xs[nx - 1];
+        knots[nx + 5] = xs[nx - 1];
+        */
+
+        // use uniform grid of knots
+        nk = 20;
+        knots = new float[nk + 4];
+        knots[0] = xs[0];
+        knots[1] = xs[0];
+        knots[2] = xs[0];
+        for(int i = 3; i<nk+1;i++) {
+          knots[i] = (i-3f) / (nk-1);
+        }
+        knots[nk] = xs[nx - 1];
+        knots[nk + 1] = xs[nx - 1];
+        knots[nk + 2] = xs[nx - 1];
+        knots[nk + 3] = xs[nx - 1];
+
+        if (nx < 4) {
           report = new SBART_Report();
           report.leverage = new double[0];
@@ -160,4 +184,7 @@
 
         float[] coeff = new float[nk];
+        float[] leverage = new float[nx];
+        float[] y_smoothed = new float[nx];
+
 
         // working arrays for sbart
@@ -172,11 +199,14 @@
         float[] sg3 = new float[nk];
         int ld4 = 4;
-        float[,] adb = new float[nk, ld4];
+        float[,] adb = new float[ld4, nk];
 
         float[,] p1ip = new float[nk, ld4];
         int ldnk = nk + 4;
-        float[,] p2ip = new float[nk, ldnk];
-
-        SBART.sbart_x64(xs, ys, ws, ref nx, knots, ref nk, coeff, y_smoothed, leverage, ref crit, ref icrit, 
+        float[,] p2ip = new float[nk, nx];
+
+        SBART.sbart_x64(xs.Take(nx).ToArray(), ys.Take(nx).ToArray(), ws.Take(nx).ToArray(), ref nx, 
+          knots, ref nk, 
+          coeff, y_smoothed, leverage, 
+          ref crit, ref icrit, 
           ref smoothingParameter, ref smoothingParameterIndicator, ref lowerSmoothingParameter, ref upperSmoothingParameter,
           ref tol, ref isetup, 
Index: branches/MathNetNumerics-Exploration-2789/Main/Program.cs
===================================================================
--- branches/MathNetNumerics-Exploration-2789/Main/Program.cs	(revision 15458)
+++ branches/MathNetNumerics-Exploration-2789/Main/Program.cs	(revision 15459)
@@ -12,12 +12,24 @@
   class Program {
     static void Main(string[] args) {
-      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider();
-      var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Poly")));
-      // var provider = new HeuristicLab.Problems.Instances.DataAnalysis.RegressionRealWorldInstanceProvider();
-      // var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Chem")));
+
+      var xs = HeuristicLab.Common.SequenceGenerator.GenerateSteps(-3.5, 3.5, 0.02, includeEnd: true).ToArray();
+      var ys = xs.Select(xi => (1.0 / (Math.Sqrt(2 * Math.PI)) * Math.Exp(-0.5 * xi * xi))).ToArray();
+
+      alglib.hqrndstate state;
+      alglib.hqrndseed(1234, 5678, out state);
+      var ys_noise = ys.Select(yi => yi + alglib.hqrndnormal(state) * 0.01).ToArray();
+
+      SBART.SBART_Report rep;
+      SBART.CalculateSBART(xs, ys_noise, "y", new string[] { "x" }, 1.0f, out rep);
+
+
+      // var provider = new HeuristicLab.Problems.Instances.DataAnalysis.VariousInstanceProvider();
+      // var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Poly")));
+      var provider = new HeuristicLab.Problems.Instances.DataAnalysis.RegressionRealWorldInstanceProvider();
+      var problemData = provider.LoadData(provider.GetDataDescriptors().First(dd => dd.Name.Contains("Chem")));
 
       var gam = new GAM();
       gam.MaxIterations = 10;
-      gam.MaxInteractions = 3;
+      gam.MaxInteractions = 1;
       gam.Problem.ProblemData = problemData;
       gam.Start();
