Discussion:
Linear Regression
LucaLuca
2018-12-07 17:52:48 UTC
Permalink
hi,
look this pics

https://gyazo.com/1f61457f939308195d72bba5f4266bc5

i need to find linea regression

i use this formula:

A=[4 3 2 0 1 8]
B=[1 2 3 4 5 6]

regress(A,B)

is write :error: regress: y must be a column vector

i don't understand :|

i read example but i don't understand that..

i need to find a series of points that approximate my range A



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Przemek Klosowski
2018-12-07 18:29:36 UTC
Permalink
Post by LucaLuca
hi,
look this pics
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgyazo.com%2F1f61457f939308195d72bba5f4266bc5&data=02%7C01%7Cprzemek.klosowski%40nist.gov%7Cc39f54f956684fe06ae208d65c6ceccb%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C636798020232877101&sdata=d%2B1VRCbGZzh435lokc8nOMNqo2aUVdPvVfHgcU2VjNk%3D&reserved=0
i need to find linea regression
A=[4 3 2 0 1 8]
B=[1 2 3 4 5 6]
regress(A,B)
is write :error: regress: y must be a column vector
regress(A',B') resolves that issue, but your B/A data doesn't look like
your picture, so I am not sure if that's what you need.

By the way, for simple linear regression, you can do polyfit(x,y,1)
Post by LucaLuca
i don't understand :|
i read example but i don't understand that..
i need to find a series of points that approximate my range A
Do you mean some sort of linear approximation of A based on fitted data?

polyval(polyfit(x,y,1),x)
LucaLuca
2018-12-08 00:06:51 UTC
Permalink
hi,
i try this example :

function esercizio_interpolazione()

pkg load statistics

a=[4 5 6 -1 0 4 -2 0 -3]

b=[1 2 3 4 5 6 7 8 9]

yi =polyfit(a',b',1)

hold on
plot(b',a','b')

plot(yi,'c')
endfunction

look this pics:

https://gyazo.com/521d0d62cb33d334251e374c27fdce92







--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Marco Atzeri
2018-12-08 07:14:23 UTC
Permalink
Post by LucaLuca
hi,
function esercizio_interpolazione()
pkg load statistics
a=[4 5 6 -1 0 4 -2 0 -3]
b=[1 2 3 4 5 6 7 8 9]
yi =polyfit(a',b',1)
Luca,

you should read the documentation with some attention

-- P = polyfit (X, Y, N)
-- [P, S] = polyfit (X, Y, N)
-- [P, S, MU] = polyfit (X, Y, N)
Return the coefficients of a polynomial P(X) of degree N that
minimizes the least-squares-error of the fit to the points '[X,
Y]'.


You are inverting X and Y


yi =polyfit(b',a',1)
yi =

-0.90000 5.94444
Post by LucaLuca
hold on
plot(b',a','b')
plot(yi,'c')
endfunction
https://gyazo.com/521d0d62cb33d334251e374c27fdce92
---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren g
LucaLuca
2018-12-08 09:14:27 UTC
Permalink
hi,

i don't understand

if i want to get this line :

https://gyazo.com/942676a11228bc3c610419faa0867bc7


how can i do it? :(



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Marco Atzeri
2018-12-08 11:26:41 UTC
Permalink
Post by LucaLuca
hi,
i don't understand
https://gyazo.com/942676a11228bc3c610419faa0867bc7
how can i do it? :(
Luca,
I understand that learning a new language is difficult, but it seems
you need to follow some tutorial for the basis.
Almost all your questions are very elementary.


polyfit provides the coefficients of N grade polinomial
that fit the data.

For grade 1 the polinomial is m*x+c so

yi =polyfit(b',a',1)
yi =

-0.90000 5.94444

where yi(1) is "m" and yi(2) is "c"

and the Y of the given line for the same x data will be

y=b*yi(1)+yi(2)
y =

Columns 1 through 8:

5.04444 4.14444 3.24444 2.34444 1.44444 0.54444 -0.35556
-1.25556

Column 9:

-2.15556

and you can plot the data and the line together with

plot(b,a,b,y)

I hope that this is enough to clarify you the matter

Regards
Marco

---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus
LucaLuca
2018-12-08 12:48:10 UTC
Permalink
thank you very kind for your patience



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Marco Atzeri
2018-12-07 18:30:53 UTC
Permalink
Post by LucaLuca
hi,
look this pics
https://gyazo.com/1f61457f939308195d72bba5f4266bc5
i need to find linea regression
A=[4 3 2 0 1 8]
B=[1 2 3 4 5 6]
regress(A,B)
is write :error: regress: y must be a column vector
i don't understand :|
you give rows, it needs columns

regress(A',B')
ans = 0.75824
Post by LucaLuca
i read example but i don't understand that..
i need to find a series of points that approximate my range A
---
Diese E-Mail wurde von Avast Antivirus-Software auf Vire
Loading...