Example: The B-spline least squares fit
A B-Spline least squares fit to data is computed. The value of the spline at point 4.5 is printed.
using System;
using Imsl.Math;
public class BsLeastSquaresEx1
{
public static void Main(String[] args)
{
double[] x = new double[]{0, 1, 2, 3, 4, 5, 8, 9, 10};
double[] y = new double[]{1.0, 0.8, 2.4, 3.1, 4.5,
5.8, 6.2, 4.9, 3.7};
BsLeastSquares bs = new BsLeastSquares(x, y, 5);
double bsv = bs.Eval(4.5);
Console.Out.WriteLine("The computed B-spline value at point " +
"4.5 is " + bsv);
}
}
Output
The computed B-spline value at point 4.5 is 5.22855432359694
Link to C# source.