n = 5000; p = 2; X = rand(n,p); w = round((rand(p,1)-.5)*30) yhat = X*w; figure(1);clf; scatter(X(:,1),X(:,2),40,yhat(:),'filled'); colorbar set(gca,'FontSize',20) xlabel('feature 1') ylabel('feature 2') %% n = 50; x = linspace(-1,1,n)'; X = [x.^3 x.^2 x ones(n,1)]; p = 4; w = rand(p,1)-.5; yhat = X*w; figure(2); plot(x,yhat,'linewidth',3); set(gca,'fontsize',20); xlabel('x') ylabel('yhat')