//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testTwoD() public virtual void testTwoD() { BasisFunctionKnots knots1 = BasisFunctionKnots.fromInternalKnots(KNOTS, 2); BasisFunctionKnots knots2 = BasisFunctionKnots.fromInternalKnots(KNOTS, 3); IList <System.Func <double[], double> > set = GENERATOR.generateSet(new BasisFunctionKnots[] { knots1, knots2 }); //pick of one of the basis functions for testing int index = FunctionUtils.toTensorIndex(new int[] { 3, 3 }, new int[] { knots1.NumSplines, knots2.NumSplines }); System.Func <double[], double> func = set[index]; assertEquals(1.0 / 3.0, func(new double[] { 2.0, 2.0 }), 0.0); assertEquals(1.0 / 2.0, func(new double[] { 2.5, 2.0 }), 0.0); assertEquals(1.0 / 8.0 / 48.0, func(new double[] { 1.5, 3.5 }), 0.0); assertEquals(0.0, func(new double[] { 4.0, 2.5 }), 0.0); }
/// <summary> /// Fits a curve to x-y data. </summary> /// <param name="x"> The independent variables </param> /// <param name="y"> The dependent variables </param> /// <param name="sigma"> The error (or tolerance) on the y variables </param> /// <param name="xa"> The lowest value of x </param> /// <param name="xb"> The highest value of x </param> /// <param name="nKnots"> Number of knots (note, the actual number of basis splines and thus fitted weights, equals nKnots + degree-1) </param> /// <param name="degree"> The degree of the basis function - 0 is piecewise constant, 1 is a sawtooth function (i.e. two straight lines joined in the middle), 2 gives three /// quadratic sections joined together, etc. For a large value of degree, the basis function tends to a gaussian </param> /// <param name="lambda"> The weight given to the penalty function </param> /// <param name="differenceOrder"> applies the penalty the nth order difference in the weights, so a differenceOrder of 2 will penalise large 2nd derivatives etc </param> /// <returns> The results of the fit </returns> public virtual GeneralizedLeastSquareResults <double> solve(IList <double> x, IList <double> y, IList <double> sigma, double xa, double xb, int nKnots, int degree, double lambda, int differenceOrder) { IList <System.Func <double, double> > bSplines = _generator.generateSet(BasisFunctionKnots.fromUniform(xa, xb, nKnots, degree)); return(_gls.solve(x, y, sigma, bSplines, lambda, differenceOrder)); }