Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,15 @@
|
|||
REAL :: n=10, x(n), y(n), m=3, p(m)
|
||||
|
||||
x = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
y = (1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321)
|
||||
|
||||
p = 2 ! initial guess for the polynom's coefficients
|
||||
|
||||
SOLVE(NUL=Theory()-y(nr), Unknown=p, DataIdx=nr, Iters=iterations)
|
||||
|
||||
WRITE(ClipBoard, Name) p, iterations
|
||||
|
||||
FUNCTION Theory()
|
||||
! called by the solver of the SOLVE function. All variables are global
|
||||
Theory = p(1)*x(nr)^2 + p(2)*x(nr) + p(3)
|
||||
END
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
function polyfit(x, y, n)
|
||||
A = [ float(x[i])^p for i = 1:length(x), p = 0:n ]
|
||||
A \ y
|
||||
end
|
||||
3
Task/Polynomial-regression/R/polynomial-regression.r
Normal file
3
Task/Polynomial-regression/R/polynomial-regression.r
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
x <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
y <- c(1, 6, 17, 34, 57, 86, 121, 162, 209, 262, 321)
|
||||
coef(lm(y ~ x + I(x^2)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue