%function [ output_args ] = Untitled6( input_args )
%UNTITLED6 Summary of this function goes here
%   Detailed explanation goes here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  the codes following describle the algorithm of Spline, and are written
%  according the Python codes least_square.py and algrothims on page 112
%  
%  -----Xueli Huang 9/20/2010
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%produce a array, starts with -3, end 9.95, and step is 0.05. We use Linear
%regression on each range of step
%x=[-3:0.05:9.95];

%produce two Gussian distrion with the noise 2.5 and
%3.2 seperatly
%y=2.5*exp(-x.^2/9)+3.2*exp(-(x-0.5).^2/4) + normrnd(0,1,[1 length(x)]);

%dim
%nParam = 2;

%A = zeros(length(x),nParam);

%A(:,1)=exp(-(x.^2)/9);
%A(:,2) = exp(-(x*0.5).^2/4);

%calculate the linear-square---Ax=y resolution,min(pow(||y-A'x||,2))
%p=(inv(A'*A)*A'*y')

%draw the graph
%plot(x,y,'.',x,p(1)*A(:,1)+p(2)*A(:,2),'x');

%end
 %This generates a sine-like spline curve and samples it over a finer mesh:
        x = 0:10;  
        y = sin(x);
        xx = 0:0.25:10;
        pp=spline(x,y)
        %spline returns the infomation of the cubic polynomial function
        %created between the breakpoints
        yy = ppval(pp,xx);
       % yy = spline(x,y,xx);
        plot(x,y,'o',xx,yy);
        
        
        %another example
       %x = -4:4; 
       %y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];
       %cs = spline(x,y);
       %xx = linspace(-4,4,101);
       %plot(x,y,'o',xx,ppval(cs,xx),'-');
        
        

