-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
149 lines (104 loc) · 4.27 KB
/
script.js
File metadata and controls
149 lines (104 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
let dateStatistice = [
]
//let dateStatistice =[]
let nrDataAdded = 0
for(let i = 0;i<dateStatistice.length;i++) {
var newRow = document.createElement("tr");
var newCellIdx = document.createElement("td");
var newCellXi = document.createElement("td");
var newCellYi = document.createElement("td");
newCellIdx.innerHTML = parseFloat(dateStatistice[i]["idx"]);
newCellXi.innerHTML = parseFloat(dateStatistice[i]["x"]);
newCellYi.innerHTML = parseFloat(dateStatistice[i]["y"]);
newRow.append(newCellIdx);
newRow.append(newCellXi);
newRow.append(newCellYi);
nrDataAdded+=1;
document.getElementById("dateStatisticeTabel").appendChild(newRow)
}
const addline = ()=>{
if ( isNaN(parseFloat(document.getElementById("xinumar").value)) || isNaN(parseFloat(document.getElementById("yinumar").value)) ){
alert('WAI CUM TREBUIE')
}
else {
dateStatistice.push({idx:nrDataAdded,x:parseFloat(document.getElementById("xinumar").value),y:parseFloat(document.getElementById("yinumar").value)})
var newRow = document.createElement("tr");
var newCellIdx = document.createElement("td");
var newCellXi = document.createElement("td");
var newCellYi = document.createElement("td");
newCellIdx.innerHTML = parseFloat(nrDataAdded);
newCellXi.innerHTML = parseFloat(document.getElementById("xinumar").value);
newCellYi.innerHTML = parseFloat(document.getElementById("yinumar").value);
newRow.append(newCellIdx);
newRow.append(newCellXi);
newRow.append(newCellYi);
nrDataAdded+=1;
document.getElementById("dateStatisticeTabel").appendChild(newRow)
}
}
function suma(coloana) {
let sum = 0
coloana == 1 ? chColoana = "idx" : chColoana = "y"
for(var i = 0;i<dateStatistice.length;i++){
sum += parseFloat(dateStatistice[i][chColoana])
}
return sum
}
function sumaPartatelor(coloana) {
let sum = 0
coloana == 1 ? chColoana = "idx" : chColoana = "y"
for(var i = 0;i<dateStatistice.length;i++){
sum += Math.pow(parseFloat(dateStatistice[i][chColoana]),2)
}
return sum
}
function produsInterCol() {
let sum = 0
for(var i = 0;i<dateStatistice.length;i++){
sum += parseFloat(dateStatistice[i].idx)*parseFloat(dateStatistice[i].y)
}
return sum
}
function calculeaza_final() {
}
let [a,b,c] = [0,0,0]
// FUNCTII PENTRU CALCULE IN MATRICE ----------------------------------------------------------------
function determinant() {
function subDet() {
let det = dateStatistice.length*sumaPartatelor(1) - suma(1)*suma(1)
let deta0 = suma(2)*sumaPartatelor(1) - produsInterCol()*suma(1)
let deta1 = dateStatistice.length*produsInterCol() - suma(1)*suma(2)
return [det,deta0,deta1]
}
[a,b,c] = subDet()
return subDet()
}
let [ai,ax] = [0,0]
function coef(det,det0,det1) {
let a0 = det0/det
let a1 = det1/det
return [a0,a1]
}
[ai,ax] - coef(a,b,c)
// PROGRAMUL PROPRIU ZIS ------------------------------------------------------------
let coloana = document.getElementById("coloana").value
function calculTabel() {
let xipentrutabel = suma(1);
let yipentrutabel = suma(2);
let xipatrattabel = sumaPartatelor(1);
let produsintercl = produsInterCol();
let [det,det0,det1] = determinant();
let [a0,a1]=[0,0]
setTimeout([a0,a1] = coef(det,det0,det1),50)
document.getElementById("xi").innerHTML=xipentrutabel.toFixed(3)
document.getElementById("yi").innerHTML=yipentrutabel.toFixed(3)
document.getElementById("xi2").innerHTML=xipatrattabel.toFixed(3)
document.getElementById("xiyi").innerHTML=produsintercl.toFixed(3)
document.getElementById("det").innerHTML=det.toFixed(3)
document.getElementById("det0").innerHTML=det0.toFixed(3)
document.getElementById("det1").innerHTML=det1.toFixed(3)
setTimeout(document.getElementById("a0").innerHTML=a0.toFixed(3),70)
setTimeout(document.getElementById("a1").innerHTML=a1.toFixed(3),70)
setTimeout(document.getElementById("inserta0").innerHTML=a0.toFixed(3),70)
setTimeout(document.getElementById("inserta1").innerHTML=a1.toFixed(3),70)
}