Least Squares

Data points are data[[1]] thru data[[m]], associated knots are in knot where m>> n, n being the degree of the approximating curve. The coefficient matrix vandermonde has m+1 rows (a lot) and n+1 colums.

approx[n_,knot_,data_]:=
(m=Length[data]-1;
vandermonde=Table[BernsteinBasis[n,j-1,knot[[i]]],{i,1,m+1},{j,1,n+1}];
bez=LinearSolve[Transpose[vandermonde].vandermonde,Transpose[vandermonde].data];
dplot=ListPlot[data];
points=Graphics[{PointSize[0.015],Point[bez]}];
bplot=ListLinePlot[bez];
curve[t_]:=Sum[BernsteinBasis[n,i,t]*bez[[i+1]],{i,0,n}];
cplot=ParametricPlot[curve[t],{t,0,1},PlotStyle->{Thick,Green}];
Show[{cplot,points,bplot,dplot}]
);

n=7;
m=100;
knot=Table[t,{t,0.0,1.0,1/m}];

data1=Table[{t,Sqrt[t]+0.4RandomReal[]},{t,0.0,10.0,10/m}];
(* play with creating an outlier *)
(* data1[[50,2]] = -5; *) 
approx[n,knot,data1]

n=12;
m=200;
knot=Table[t,{t,0.0,1.0,1/m}];

data1=Table[{t*Cos[t]+0.4*RandomReal[], t*Sin[t]+0.4RandomReal[]},{t,0.0,10.0,10/m}];
approx[n,knot,data1]