File:LinearRegression.svg

Uploaded by F l a n k e r
Upload date 2008-10-28T12:50:33Z
MIME type image/svg+xml
Dimensions 600 × 480 px
File size 40.8 KB

Summary

Description Illustration of linear regression on a data set.
Date
Source self-made in Gnuplot.
Author Berland
Other versions

Gnuplot source code

set terminal svg fname "Helvetica" fsize 25
set output "LinearRegression.svg"
set key left
set xtics axis 4.0,0.5
set ytics nomirror 1
set border 2
f(x) = a*x + b
fit f(x) 'randpts' using 1:2 via a,b
set yrange [-0.9:4]
plot 'randpts' with points pointtype 7 pointsize 0.3 title 'Datapoints', \
	f(x) with lines linetype 3 linewidth 3 title 'Regression',  \
	0 with lines linetype -1 notitle

The datafile 'randpts' was made in GNU Octave using the commands

f = fopen('randpts', 'w');
for i=1:200; 
   x=rand(1); 
   y=0.2*randn(1) + 3*x + 0.35; 
   fprintf(f, '%g %g\n', x, y); 
end
fclose(f)

(identical code also works in Matlab.)

Licensing

Public domain This work has been released into the public domain by its author, Berland. This applies worldwide.
In some countries this may not be legally possible; if so:
Berland grants anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

24 June 2007

41,735 byte

image/svg+xml

2b3854e7964499c553222356de97bb612e928cd8

Category:Linear regression Category:PD-self Category:Self-published work