-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
751 lines (735 loc) · 29.9 KB
/
script.js
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
//for input file
$(".custom-file-input").on("change", function() {
var file_name = $(this).val().split("\\").pop();
$(this).siblings(".custom-file-label").addClass("selected").html(file_name);
});
//-------------------------
//get the input file data
function init() {
document.getElementById('file-input').addEventListener('change', handleFileSelect, false);
}
function handleFileSelect(event) {
const reader = new FileReader();
reader.onload = handleFileLoad;
reader.readAsText(event.target.files[0]);
}
function handleFileLoad(event){
console.log(event);
input_raw_file = event.target.result;
}
//-------------------------
//inputing
function inputing() {
//get the file input extension
var extension = document.getElementById("file-input").value.split(".")[1];
console.log("File Extension: ." + extension);
var input_data = [];
if (extension == "dat" || extension == "txt") {
//converting input data from string to array
var input_array = input_raw_file.split("\n").map(function (d) {
return d.split("\t");
});
//determining x and y
var input_x = [];
var input_y = [];
for (var i = 0;i < input_array.length;i++) {
input_x[i] = input_array[i][0];
input_y[i] = input_array[i][1];
if (input_x[i] == "-999.25") {
input_x[i] = "0";
}
else {
input_x[i] = input_x[i];
}
if (input_y[i] == "-999.25") {
input_y[i] = "0";
}
else {
input_y[i] = input_y[i];
}
}
if (typeof input_y[0] == "string") {
console.log("Input X: " + input_x);
console.log("Input Y: " + input_y);
input_data = [input_x, input_y];
function_error_recovering();
}
else {
function_error_handling();
}
}
else {
function_error_handling();
}
return input_data;
}
//-------------------------
//error handling
function function_error_handling() {
input_data = [0];
document.getElementById("result").innerHTML = "<h5>" + "ERROR" + "</h5>";
$("#result").removeClass("border-primary");
$("#result, #data-req").addClass("border-danger text-danger");
document.getElementById("result").scrollIntoView();
}
//-------------------------
//error recovering
function function_error_recovering() {
$("#result, #data-req").removeClass("border-danger text-danger");
$("#result").addClass("border-primary");
}
//-------------------------
//functions
function function_median(input) {
var length = input.length;
var input_copy = Array.from(input);
var input_sorted = input_copy.sort(function(a, b){return a - b;});
var median = [];
if (length % 2 == 1) {
var median_index = ((length / 2) + 0.5) - 1;
median = [input_sorted[median_index]];
}
else {
var median_index_1 = (length / 2) - 1;
var median_index_2 = ((length / 2) + 1) - 1;
median = [input_sorted[median_index_1], input_sorted[median_index_2]];
}
return median;
}
function function_modes(input) {
var frequency = {};
var maxFreq = 0;
var modes = [];
for (var i in input) {
frequency[input[i]] = (frequency[input[i]] || 0) + 1;
if (frequency[input[i]] > maxFreq) {
maxFreq = frequency[input[i]];
}
}
for (var j in frequency) {
if (frequency[j] == maxFreq) {
modes.push(j);
}
}
return modes;
}
function function_percentile(input, percent) {
var length = input.length;
var input_copy = Array.from(input);
var input_sorted = input_copy.sort(function(a, b){return a - b;});
var percentile_area = Math.floor((length * percent) / 100);
var percentile_index = percentile_area + 1;
var input_sorted_reduced = [];
for (var i = 0;i < percentile_index;i++) {
input_sorted_reduced[i] = input_sorted[i];
}
var percentile = Math.max(...input_sorted_reduced);
return percentile;
}
function function_times(input_1, input_2) {
var length = input_1.length;
var input_times = [];
for (var i = 0;i < length;i++) {
input_times[i] = input_1[i] * input_2[i];
}
return input_times;
}
function function_sum(input) {
var sum = eval(input.join("+"));
return sum;
}
function function_mean(input) {
var length = input.length;
var sum = function_sum(input);
var mean = sum / length;
return mean;
}
function function_harmonic_mean(input) {
var length = input.length;
var per_value = [];
for (var i = 0;i < length;i++) {
per_value[i] = 1 / input[i];
}
var sum_per_value = function_sum(per_value);
var hmean = length / sum_per_value;
return hmean;
}
function function_square(input) {
var length = input.length;
var square = [];
for (var i = 0;i < length;i++) {
square[i] = Math.pow(input[i], 2);
}
return square;
}
function function_cubic(input) {
var length = input.length;
var cubic = [];
for (var i = 0;i < length;i++) {
cubic[i] = Math.pow(input[i], 3);
}
return cubic;
}
function function_square_sum(input) {
var sum = function_sum(input);
var square_sum = Math.pow(sum, 2);
return square_sum;
}
function function_sum_square(input) {
var square = function_square(input);
var sum_square = function_sum(square);
return sum_square;
}
function function_mean_square(input) {
var length = input.length;
var sum_square = function_sum_square(input);
var mean_square = sum_square / length;
return mean_square;
}
function function_root_mean_square(input) {
var mean_square = function_mean_square(input);
var root_mean_square = Math.sqrt(mean_square);
return root_mean_square;
}
function function_variance(input) {
var length = input.length;
var mean = function_mean(input);
var input_minus_mean = [];
for (var i = 0;i < length;i++) {
input_minus_mean[i] = input[i] - mean;
}
var square_input_minus_mean = function_square(input_minus_mean);
var sum_square_input_minus_mean = function_sum(square_input_minus_mean);
var variance = sum_square_input_minus_mean / (length - 1);
return variance;
}
function function_standard_deviation(input) {
var variance = function_variance(input);
var standard_deviation = Math.sqrt(variance);
return standard_deviation;
}
function function_standardization(input) {
var length = input.length;
var mean = function_mean(input);
var standard_deviation = function_standard_deviation(input);
var input_minus_mean = [];
for (var i = 0;i < length;i++) {
input_minus_mean[i] = input[i] - mean;
}
var standardization = [];
for (var j = 0;j < length;j++) {
standardization[j] = input_minus_mean[j] / standard_deviation;
}
return standardization;
}
function function_skewness(input) {
var length = input.length;
var mean = function_mean(input);
var input_minus_mean = [];
for (var i = 0;i < length;i++) {
input_minus_mean[i] = input[i] - mean;
}
var cubic_input_minus_mean = function_cubic(input_minus_mean);
var sum_cubic_minus_mean = function_sum(cubic_input_minus_mean);
var standard_deviation = function_standard_deviation(input);
var cubic_standard_deviation = Math.pow(standard_deviation, 3);
var skewness = (sum_cubic_minus_mean * length) / ((length - 1) * (length - 2) * cubic_standard_deviation);
return skewness;
}
function function_covariance(input_1, input_2) {
var length = input_1.length;
var mean_1 = function_mean(input_1);
var mean_2 = function_mean(input_2);
var input_1_minus_mean = [];
for (var i = 0;i < length;i++) {
input_1_minus_mean[i] = input_1[i] - mean_1;
}
var input_2_minus_mean = [];
for (var j = 0;j < length;j++) {
input_2_minus_mean[j] = input_2[j] - mean_2;
}
var input_times_minus_mean_times = function_times(input_1_minus_mean, input_2_minus_mean);
var sum_input_times_minus_mean_times = function_sum(input_times_minus_mean_times);
var covariance = sum_input_times_minus_mean_times / (length - 1);
return covariance;
}
function function_correlation_coefficient(input_1, input_2) {
var length = input_1.length;
var sum_1 = function_sum(input_1);
var sum_2 = function_sum(input_2);
var input_times = function_times(input_1, input_2);
var sum_times = function_sum(input_times);
var square_sum_1 = function_square_sum(input_1);
var square_sum_2 = function_square_sum(input_2);
var sum_square_1 = function_sum_square(input_1);
var sum_square_2 = function_sum_square(input_2);
var correlation_coefficient = ((length * (sum_times)) - (sum_1 * sum_2)) / (Math.sqrt((((length * sum_square_1) - square_sum_1) * ((length * sum_square_2) - square_sum_2))));
return correlation_coefficient;
}
function function_determination_coefficient(input_1, input_2) {
var correlation_coefficient = function_correlation_coefficient(input_1, input_2);
var determination_coefficient = Math.pow(correlation_coefficient, 2);
return determination_coefficient;
}
function function_linear_regression(input_1, input_2) {
var length = input_1.length;
var sum_1 = function_sum(input_1);
var sum_2 = function_sum(input_2);
var mean_1 = function_mean(input_1);
var mean_2 = function_mean(input_2);
var input_1_minus_mean = [];
for (var i = 0;i < length;i++) {
input_1_minus_mean[i] = input_1[i] - mean_1;
}
var input_2_minus_mean = [];
for (var j = 0;j < length;j++) {
input_2_minus_mean[j] = input_2[j] - mean_2;
}
var input_times_minus_mean_times = function_times(input_1_minus_mean, input_2_minus_mean);
var sum_input_times_minus_mean_times = function_sum(input_times_minus_mean_times);
var sum_square_input_1_minus_mean = function_sum_square(input_1_minus_mean);
var slope = sum_input_times_minus_mean_times / sum_square_input_1_minus_mean;
var intercept = (sum_2 - (slope * sum_1)) / length;
var slope_string = "";
var intercept_string = "";
if (slope == "1") {
slope_string = "X";
}
else if (slope == "0") {
slope_string = "";
}
else if (slope == "-1") {
slope_string = "- X";
}
else {
slope_string = slope + "X";
}
if (intercept > "0") {
intercept_string = "+" + " " + intercept;
}
else if (intercept == "0") {
intercept_string = "";
}
else if (intercept < "0") {
intercept_string = "-" + " " + Math.abs(intercept);
}
else {
intercept_string = intercept;
}
var regression_equation = "<i>" + "Y = " + slope_string + " " + intercept_string +"</i>";
var linear_regression = [slope, intercept, regression_equation];
return linear_regression;
}
//-------------------------
//calculation refers to x
function function_x_result() {
input = inputing();
input = input[0];
document.getElementById("result").innerHTML = "<h5>" + "Values:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_median_x_result() {
input = inputing();
input = function_median(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Median:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_percentile_x_result() {
input = inputing();
input_25 = function_percentile(input[0], 25);
input_50 = function_percentile(input[0], 50);
input_75 = function_percentile(input[0], 75);
document.getElementById("result").innerHTML =
"<h5>" + "25% Percentile:" + "</h5>" + "<i>" + input_25 + "</i>" + "</br>" + "</br>" +
"<h5>" + "50% Percentile:" + "</h5>" + "<i>" + input_50 + "</i>" + "</br>" + "</br>" +
"<h5>" + "75% Percentile:" + "</h5>" + "<i>" + input_75 + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_modes_x_result() {
input = inputing();
input = function_modes(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Modes:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_sum_x_result() {
input = inputing();
input = function_sum(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Sum:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_mean_x_result() {
input = inputing();
input = function_mean(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Mean:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_harmonic_mean_x_result() {
input = inputing();
input = function_harmonic_mean(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Harmonic Mean:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_square_x_result() {
input = inputing();
input = function_square(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Square:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_cubic_x_result() {
input = inputing();
input = function_cubic(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Cubic:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_square_sum_x_result() {
input = inputing();
input = function_square_sum(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Square Sum:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_sum_square_x_result() {
input = inputing();
input = function_sum_square(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Sum Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_mean_square_x_result() {
input = inputing();
input = function_mean_square(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Mean Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_root_mean_square_x_result() {
input = inputing();
input = function_root_mean_square(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Root Mean Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_variance_x_result() {
input = inputing();
input = function_variance(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Variance:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_standard_deviation_x_result() {
input = inputing();
input = function_standard_deviation(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Standard Deviation:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_standardization_x_result() {
input = inputing();
input = function_standardization(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Standardization:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_skewness_x_result() {
input = inputing();
input = function_skewness(input[0]);
document.getElementById("result").innerHTML = "<h5>" + "Skewness:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
//-------------------------
//calculation refers to y
function function_y_result() {
input = inputing();
input = input[1];
document.getElementById("result").innerHTML = "<h5>" + "Values:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_median_y_result() {
input = inputing();
input = function_median(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Median:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_modes_y_result() {
input = inputing();
input = function_modes(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Modes:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_percentile_y_result() {
input = inputing();
input_25 = function_percentile(input[1], 25);
input_50 = function_percentile(input[1], 50);
input_75 = function_percentile(input[1], 75);
document.getElementById("result").innerHTML =
"<h5>" + "25% Percentile:" + "</h5>" + "<i>" + input_25 + "</i>" + "</br>" + "</br>" +
"<h5>" + "50% Percentile:" + "</h5>" + "<i>" + input_50 + "</i>" + "</br>" + "</br>" +
"<h5>" + "75% Percentile:" + "</h5>" + "<i>" + input_75 + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_sum_y_result() {
input = inputing();
input = function_sum(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Sum:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_mean_y_result() {
input = inputing();
input = function_mean(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Mean:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_harmonic_mean_y_result() {
input = inputing();
input = function_harmonic_mean(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Harmonic Mean:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_square_y_result() {
input = inputing();
input = function_square(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Square:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_cubic_y_result() {
input = inputing();
input = function_cubic(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Cubic:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_square_sum_y_result() {
input = inputing();
input = function_square_sum(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Square Sum:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_sum_square_y_result() {
input = inputing();
input = function_sum_square(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Sum Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_mean_square_y_result() {
input = inputing();
input = function_mean_square(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Mean Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_root_mean_square_y_result() {
input = inputing();
input = function_root_mean_square(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Root Mean Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_variance_y_result() {
input = inputing();
input = function_variance(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Variance:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_standard_deviation_y_result() {
input = inputing();
input = function_standard_deviation(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Standard Deviation:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_standardization_y_result() {
input = inputing();
input = function_standardization(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Standardization:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_skewness_y_result() {
input = inputing();
input = function_skewness(input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Skewness:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
//-------------------------
//calculation refers to xy
function function_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Values:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_median_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_median(input);
document.getElementById("result").innerHTML = "<h5>" + "Median:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_modes_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_modes(input);
document.getElementById("result").innerHTML = "<h5>" + "Modes:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_percentile_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input_25 = function_percentile(input, 25);
input_50 = function_percentile(input, 50);
input_75 = function_percentile(input, 75);
document.getElementById("result").innerHTML =
"<h5>" + "25% Percentile:" + "</h5>" + "<i>" + input_25 + "</i>" + "</br>" + "</br>" +
"<h5>" + "50% Percentile:" + "</h5>" + "<i>" + input_50 + "</i>" + "</br>" + "</br>" +
"<h5>" + "75% Percentile:" + "</h5>" + "<i>" + input_75 + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_sum_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_sum(input);
document.getElementById("result").innerHTML = "<h5>" + "Sum:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_mean_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_mean(input);
document.getElementById("result").innerHTML = "<h5>" + "Mean:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_harmonic_mean_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_harmonic_mean(input);
document.getElementById("result").innerHTML = "<h5>" + "Harmonic Mean:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_square_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_square(input);
document.getElementById("result").innerHTML = "<h5>" + "Square:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_cubic_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_cubic(input);
document.getElementById("result").innerHTML = "<h5>" + "Cubic:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_square_sum_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_square_sum(input);
document.getElementById("result").innerHTML = "<h5>" + "Square Sum:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_sum_square_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_sum_square(input);
document.getElementById("result").innerHTML = "<h5>" + "Sum Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_mean_square_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_mean_square(input);
document.getElementById("result").innerHTML = "<h5>" + "Mean Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_root_mean_square_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_root_mean_square(input);
document.getElementById("result").innerHTML = "<h5>" + "Root Mean Square:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_variance_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_variance(input);
document.getElementById("result").innerHTML = "<h5>" + "Variance:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_standard_deviation_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_standard_deviation(input);
document.getElementById("result").innerHTML = "<h5>" + "Standard Deviation:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_standardization_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_standardization(input);
document.getElementById("result").innerHTML = "<h5>" + "Standardization:" + "</h5>" + "<i>" + input.join("<br/>") + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_skewness_x_y_result() {
input = inputing();
input = function_times(input[0], input[1]);
input = function_skewness(input);
document.getElementById("result").innerHTML = "<h5>" + "Skewness:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
//-------------------------
//calculation refers to x and y
function function_covariance_result() {
input = inputing();
input = function_covariance(input[0], input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Coavariance:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_correlation_coefficient_result() {
input = inputing();
input = function_correlation_coefficient(input[0], input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Correlation Coefficient:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_determination_coefficient_result() {
input = inputing();
input = function_determination_coefficient(input[0], input[1]);
document.getElementById("result").innerHTML = "<h5>" + "Determination Coefficient:" + "</h5>" + "<i>" + input + "</i>";
document.getElementById("result").scrollIntoView();
}
function function_linear_regression_result() {
input = inputing();
input = function_linear_regression(input[0], input[1]);
document.getElementById("result").innerHTML =
"<h5>" + "Slope:" + "</h5>" + "<i>" + input[0] + "</i>" + "<br/>" + "<br/>" +
"<h5>" + "Intercept:" + "</h5>" + "<i>" + input[1] + "</i>" + "<br/>" + "<br/>" +
"<h5>" + "Linear Regression Equation:" + "</h5>" + "<i>" + input[2] + "</i>";
document.getElementById("result").scrollIntoView();
}
//-------------------------
//calculation panel
$(document).ready(function(){
$(".calculation-title-x").click(function(){
$(".calculation-panel-x").slideToggle("fast", function() {
if ($(this).is(":visible"))
$(this).css("display","flex");
});
});
$(".calculation-title-y").click(function(){
$(".calculation-panel-y").slideToggle("fast", function() {
if ($(this).is(":visible"))
$(this).css("display","flex");
});
});
$(".calculation-title-x-y").click(function(){
$(".calculation-panel-x-y").slideToggle("fast", function() {
if ($(this).is(":visible"))
$(this).css("display","flex");
});
});
$(".calculation-title-x-and-y").click(function(){
$(".calculation-panel-x-and-y").slideToggle("fast", function() {
if ($(this).is(":visible"))
$(this).css("display","flex");
});
});
});
//-------------------------
//copy to clipboard
function copy(selector){
var $temp = $("<div>");
$("body").append($temp);
$temp.attr("contenteditable", true)
.html($(selector).html()).select()
.on("focus", function() { document.execCommand('selectAll',false,null); })
.focus();
document.execCommand("copy");
$temp.remove();
}
//-------------------------