Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
71
Task/Multiple-regression/QB64/multiple-regression.qb64
Normal file
71
Task/Multiple-regression/QB64/multiple-regression.qb64
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
Const N = 14, M = 2, Q = 3 ' number of points and M.R. polynom degree
|
||||
|
||||
Dim X(N) As Double ' data points
|
||||
Data 1.47,1.50,1.52,1.55,1.57,1.60,1.63,1.65,1.68,1.70,1.73,1.75,1.78,1.80,1.83
|
||||
For c = LBound(X) To UBound(X)
|
||||
Read X(c)
|
||||
Next c
|
||||
Dim As Double Y(N) ' data points
|
||||
Data 52.21,53.12,54.48,55.84,57.20,58.57,59.93,61.29,63.11,64.47,66.28,68.10,69.92,72.19,74.46
|
||||
For c = LBound(Y) To UBound(Y)
|
||||
Read Y(c)
|
||||
Next c
|
||||
Dim As Double S(N), T(N) ' linear system coefficient
|
||||
Dim As Double A(M, Q) ' system to be solved
|
||||
Dim As Integer i, k, j, fila, columna
|
||||
Dim As Double z
|
||||
|
||||
For k = 0 To 2 * M
|
||||
S(k) = 0: T(k) = 0
|
||||
For i = 0 To N
|
||||
S(k) = S(k) + X(i) ^ k
|
||||
If k <= M Then T(k) = T(k) + Y(i) * X(i) ^ k
|
||||
Next i
|
||||
Next k
|
||||
|
||||
' build linear system
|
||||
For fila = 0 To M
|
||||
For columna = 0 To M
|
||||
A(fila, columna) = S(fila + columna)
|
||||
Next columna
|
||||
A(fila, columna) = T(fila)
|
||||
Next fila
|
||||
|
||||
Print "Linear system coefficents:"
|
||||
For i = 0 To M
|
||||
For j = 0 To M + 1
|
||||
Print Using "######.#"; A(i, j);
|
||||
Next j
|
||||
Print
|
||||
Next i
|
||||
|
||||
For j = 0 To M
|
||||
For i = j To M
|
||||
If A(i, j) <> 0 Then Exit For
|
||||
Next i
|
||||
If i = M + 1 Then
|
||||
Print: Print "SINGULAR MATRIX '"
|
||||
End
|
||||
End If
|
||||
For k = 0 To M + 1
|
||||
Swap A(j, k), A(i, k)
|
||||
Next k
|
||||
z = 1 / A(j, j)
|
||||
For k = 0 To M + 1
|
||||
A(j, k) = z * A(j, k)
|
||||
Next k
|
||||
For i = 0 To M
|
||||
If i <> j Then
|
||||
z = -A(i, j)
|
||||
For k = 0 To M + 1
|
||||
A(i, k) = A(i, k) + z * A(j, k)
|
||||
Next k
|
||||
End If
|
||||
Next i
|
||||
Next j
|
||||
|
||||
Print: Print "Solutions:"
|
||||
For i = 0 To M
|
||||
Print Using " #####.#######"; A(i, M + 1);
|
||||
Next i
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue