Hello,

I’m having troubles understand something about regression coefficients.

If I have two vectors:

x = [1.38, 1.98, 3.18, 3.56, 4.9, 6.21, 6.44, 7.47, 8.36, 8.81]

y = [8.19, 17.77, 20.12, 14.55, 20.17 ,31.22 ,28.94, 34.79, 40.26, 38.99]

and I would like to find out the regression coefficient I can use polyfit:

b1, b = polyfit(x,y,1)

my first question is can I get from polyfit the corrlation coeficient (I know about corrcoef, just looking for more opotions).

The second question is about a fuction I wrote: according to http://en.wikipedia.org/wiki/Regression_analysis#Linear_regression

it’s pretty easy to write a little python funcion to calculate the regression coefficients. Here is mine:

def b1(x,y):

sum1 = 0

sum2 = 0

mx = mean(x)

my = mean(y)

for i,j in zip(x,y):

sum1 =+ (i-mx)*(j-my)

print sum1

sum2 =+ (i-mx)**2

b1 = sum1/sum2

```
return b1
```

both methods yeild two different b1 values. Can anyone please tell me what wrong with my function ?

Thanks, Oz.

## ···

–

.’’`.

: :’ : We are debian.org. Lower your prices,

`.`

’ surrender your code.

`- We will add your hardware and software

distinctiveness to our own.

Resistance is futile.

```
Imagine there's no countries
It isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
```

```
You all must read 'The God Delusion'
[http://en.wikipedia.org/wiki/The_God_Delusion](http://en.wikipedia.org/wiki/The_God_Delusion)
```

when one person suffers from a delusion it is called insanity. When many people suffer from a delusion it is called religion."

Robert Pirsig, Zen and the Art of Motorcycle Maintenance