public CrossValidatedCubicSplineController(CrossValidatedCubicSpline spline)
			: base(spline.ErrorVariance)
		{
			base._minimumValue = 0;
			base._isMinimumValueIncluded = false;
			_descriptionText = "Error variance (if unknown, set it to -1) :";
			_spline = spline;
		}
Ejemplo n.º 2
0
		public void Test1()
		{
			int len = _testvals.Length;

			double[] x = new double[len];
			double[] y = new double[len];
			double[] dy = new double[len];

			for (int i = 0; i < len; i++)
			{
				x[i] = _testvals[i][0];
				y[i] = _testvals[i][1];
				dy[i] = 1;
			}

			CrossValidatedCubicSpline spline = new CrossValidatedCubicSpline();
			spline.CalculateErrorEstimates = true;

			spline.SetErrorVariance(VectorMath.ToROVector(dy), -1);
			spline.Interpolate(VectorMath.ToROVector(x), VectorMath.ToROVector(y));

			// Test the values y at the points x[i] - this are the coefficients of 0th order
			for (int i = 0; i < len; i++)
			{
				AreEqual(_refy[i], spline.Coefficient0[i], 1e-7, 0, "Coeff0[" + i.ToString() + "]");
			}

			// test the higher order coefficients
			for (int i = 0; i < len - 1; i++)
			{
				AreEqual(_expectedCoefficients[i][0], spline.Coefficient1[i], 1e-7, 0, "Coeff1[" + i.ToString() + "]");
				AreEqual(_expectedCoefficients[i][1], spline.Coefficient2[i], 1e-7, 0, "Coeff2[" + i.ToString() + "]");
				AreEqual(_expectedCoefficients[i][2], spline.Coefficient3[i], 1e-7, 0, "Coeff3[" + i.ToString() + "]");
			}

			// test the standard error estimates
			for (int i = 0; i < len; i++)
			{
				AreEqual(_expectedErrorEstimates[i], spline.ErrorEstimate[i], 1e-7, 0, "Error[" + i.ToString() + "]");
			}

			AreEqual(_expectedFitVars[0], spline.SmoothingParameter, 1e-7, 0, "SmoothingParameter");
			AreEqual(_expectedFitVars[1], spline.EstimatedDegreesOfFreedom, 1e-7, 0, "EstimatedDegreesofFreedom");
			AreEqual(_expectedFitVars[2], spline.GeneralizedCrossValidation, 1e-7, 0, "GeneralizedCrossValidation");
			AreEqual(_expectedFitVars[3], spline.MeanSquareResidual, 1e-7, 0, "MeanSquareResidual");
			AreEqual(_expectedFitVars[4], spline.EstimatedTrueMeanSquareError, 1e-7, 0, "EstimatedTrueMeanSquareError");
			AreEqual(_expectedFitVars[5], spline.EstimatedErrorVariance, 1e-7, 0, "EstimatedErrorVariance");
			AreEqual(_expectedFitVars[6], spline.MeanSquareOfInputVariance, 1e-7, 0, "MeanSquareOfInputVariance");
		}