Created
February 12, 2017 01:21
-
-
Save wdiasvargas/c0375d30c61ed156ed39034f4a3bc332 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
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]; | |
q1Arr = (values.length % 2 == 0) ? values.slice(0, (values.length / 2)) : values.slice(0, Math.floor(values.length / 2)); | |
q2Arr = values; | |
q3Arr = (values.length % 2 == 0) ? values.slice((values.length / 2), values.length) : values.slice(Math.ceil(values.length / 2), values.length); | |
medianX(q1Arr); | |
Q1=median; | |
medianX(q2Arr); | |
Q2=median; | |
medianX(q3Arr); | |
Q3=median; | |
function medianX(medianArr) { | |
count = medianArr.length; | |
median = (count % 2 == 0) ? (medianArr[(medianArr.length/2) - 1] + medianArr[(medianArr.length / 2)]) / 2 : medianArr[Math.floor(medianArr.length / 2)]; | |
return median; | |
} | |
console.log(q1Arr, q2Arr, q3Arr); | |
console.log("Quartil 1 25% "+Q1,"Quartil 2 50% "+Q2,"Quartil 3 75% "+Q3)//Quartil 1 25% 50.4481202037 Quartil 2 50% 41.83728231035 Quartil 3 75% 82.02411431499999 |
comecei a faze lo, mas o firstQuartil esta retornando [ ]
preciso que verifique isso
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gente preciso de ajuda,
baseado nesse site https://www.hackmath.net/en/calculator/quartile-q1-q3
queria fazer desse codigo um modulo pra node
Nao to conseguindo fazer essa função como modulo em node T_T
uma explicacao do que é o quartil esta aqui
http://www.mathsisfun.com/data/quartiles.html