-
-
Save enieber/17f2ab3cf2274dc1f02600849d8b21fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSizeArray(arr) { | |
return arr.lenth | |
} | |
function getModule2(arr) { | |
let size = getSizeArray(arr) | |
return size % 2 == 0 | |
} | |
function getDivide2(arr) { | |
let size = getSizeArray(arr) | |
return size / 2 | |
} | |
function firstQuartil(arr) { | |
let module2 = getModule2(arr) | |
let div2 = getDivide2(arr) | |
return (module2) ? arr.slice(0, (div2)) : arr.slice(0, Math.floor(module2)); | |
} | |
function thirdQuartil(arr) { | |
let module2 = getModule2(arr) | |
let div2 = getDivide2(arr) | |
let sizeArray = getSizeArray(values) | |
return (module2) ? arr.slice((div2), sizeArray) : arr.slice(Math.ceil(div2), sizeArray); | |
} | |
function medianX(arr) { | |
let count = getSizeArray(arr); | |
let module2 = getModule2(arr) | |
let module2help = getDivide2(arr[(getDivide2(arr)) - 1] + arr[(getDivide2(arr))]) | |
let arrDivide2 = arr[Math.floor(getDivide2(2))] | |
if (module2) { | |
return module2 | |
} else if (module2help) { | |
return module2help | |
} | |
return arrDivide2 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const values = require('./values') | |
const q1 = firstQuartil(values) | |
const q2 = values | |
const q3 = thirdQuartil(values) | |
console.log("Quartil 1 25% " + medianX(q1)) //Quartil 1 25% 50.4481202037 | |
console.log("Quartil 2 50% " + q2) //Quartil 2 50% 41.83728231035 | |
console.log("Quartil 3 75% "+ medianX(q3)) // Quartil 3 75% 82.02411431499999 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
values = [ | |
82.1467068058, | |
38.4966734016, | |
32.0008188793, | |
96.9622650244, | |
86.8058759993, | |
79.3362306586, | |
58.0055852798, | |
75.8220414787, | |
67.0149545567, | |
36.4044706595, | |
85.3345320643, | |
20.6287894419, | |
81.7456373986, | |
24.4326880876, | |
19.9944876851, | |
80.2303362813, | |
98.6854373061, | |
4.3960766433, | |
22.1212283642, | |
53.1724684800, | |
50.3620960690, | |
11.3724002897, | |
41.0039978225, | |
64.8333473234, | |
15.5894909570, | |
85.3067494504, | |
84.0015994709, | |
91.3425614815, | |
47.3171987992, | |
16.5602177445, | |
86.5891620670, | |
27.3438542203, | |
72.3398157121, | |
18.5367692487, | |
40.5793436922, | |
70.1641373485, | |
59.9469967755, | |
64.6235988325, | |
35.4129698701, | |
90.1449361797, | |
89.5436831889, | |
20.7605480631, | |
72.2822633062, | |
27.9079298572, | |
67.1159466004, | |
68.6223243990, | |
88.5802505560, | |
13.6363037261, | |
24.7355830273, | |
19.7367890419, | |
63.9377755788, | |
75.6711643900, | |
31.9382648930, | |
45.6193707884, | |
43.8147543419, | |
18.2865472284, | |
39.0358874791, | |
6.6626381087, | |
64.3532950055, | |
57.8284906640, | |
69.1947236148, | |
18.9723704594, | |
28.5984494536, | |
86.5579189727, | |
34.9384562133, | |
26.2378601208, | |
97.9248087536, | |
38.6448350638, | |
77.7968509496, | |
77.5877098686, | |
1.4398382678, | |
87.6189498380, | |
47.8376225653, | |
6.8257593391, | |
95.6884705282, | |
68.3597581018, | |
48.1638241128, | |
16.1232389894, | |
6.8025946135, | |
49.6078329777, | |
17.1302162234, | |
49.6477608677, | |
84.0468898717, | |
60.3049364974, | |
65.8149959441, | |
71.6199402320, | |
37.6571363245, | |
88.7415553423, | |
66.4689612964, | |
52.4968718552, | |
55.0881701336, | |
23.2653091083, | |
79.5475241154, | |
92.2793432818, | |
82.4489210807, | |
62.3116121280, | |
75.2383286962, | |
76.5622551190, | |
26.9191521540, | |
65.2132617394]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment