Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Polynomial-regression/Sidef/polynomial-regression.sidef
Normal file
20
Task/Polynomial-regression/Sidef/polynomial-regression.sidef
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
func regress(x, y, degree) {
|
||||
var A = Matrix.build(x.len, degree+1, {|i,j|
|
||||
x[i]**j
|
||||
})
|
||||
|
||||
var B = Matrix.column_vector(y...)
|
||||
((A.transpose * A)**(-1) * A.transpose * B).transpose[0]
|
||||
}
|
||||
|
||||
func poly(x) {
|
||||
3*x**2 + 2*x + 1
|
||||
}
|
||||
|
||||
var coeff = regress(
|
||||
10.of { _ },
|
||||
10.of { poly(_) },
|
||||
2
|
||||
)
|
||||
|
||||
say coeff
|
||||
Loading…
Add table
Add a link
Reference in a new issue