massimo sandal wrote:
javi markez bigara ha scritto:
i would like to know how to plot several linear regresions with the same group of points,
Don't understand exactly what you want to do ...
what do you mean?
however, if you dig the matplotlib and the scipy documentation, you'll find (a)how to plot points (easy) (b)how to calculate linear regressions (this one is less straightforward than it should be, however now I don't remember the details - I can check my code if you have trouble in finding it by yourself).
One easy possibility (using numpy):
In : import numpy as N
# make some sample data with noise
In : x = N.linspace(0,10,100); y = 3*x + 5 + N.random.randn(len(x))*3
In : p = N.polyfit(x, y, 1)
In : p
Out: array([ 3.02862193, 5.14341042])
In : plot(x, y, 'o')
Out: [<matplotlib.lines.Line2D instance at 0xa376aacc>]
In : plot(x, N.polyval(p,x), 'r')
Out: [<matplotlib.lines.Line2D instance at 0xa37734cc>]
Note: matplotlib also has random numbers (e.g. pylab.randn, but I think this is imported from numpy), as well as linspace and also polyfit and polyval, so importing numpy wouldn't even be necessary here. Another lin. reg. function is scipy.stats.linregress .... All roads lead to Rome.
Random number generation is the art of producing pure gibberish as quickly as possible.