Ejemplo n.º 1
0
        internal void OnlineRegression()
        {
            int n = 100;

            double[] ydata = new double[n];
            Vector[] xdata = new Vector[n];
            Vector   wTrue = Vector.FromArray(2.0, 3.0);

            for (int i = 0; i < n; i++)
            {
                xdata[i] = Vector.FromArray(Rand.Normal(), Rand.Normal());
                ydata[i] = xdata[i].Inner(wTrue);
            }
            VectorGaussian postW = BatchRegression(xdata, ydata);

            Console.WriteLine("Batch posterior over the weights: " + Environment.NewLine + postW);
            VectorGaussian postW2 = OnlineRegression(xdata, ydata);

            Console.WriteLine("Online posterior over the weights: " + Environment.NewLine + postW2);
            Assert.True(postW.MaxDiff(postW2) < 1e-10);
        }