๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ’ซ ์ˆ˜ํ•™

Day 1: Interquartile Range

HackerRank 10 days of statistics

: Day 1 note taking Interquartile Range



quartile

 

Q1

 Q1 >= 25% of the data

Q2

 Q2 >= 50% of the data

Q3

 Q3 >= 75% of the data

 Interquartile Range

  Q3-Q1


Interquartile Range(์‚ฌ๋ถ„์œ„ ๋ฒ”์œ„): the difference between first(Q1) and third(Q3) quartiles.

 




def median(arr): N = len(arr) if N%2==0: return (arr[(N//2)-1]+arr[N//2])/2 return arr[N//2] def interquartile(arr): N = len(arr) Q1 = median(arr[:N//2]) Q2 = median(arr) if N%2 == 0: Q3 = median(arr[N//2:]) else: Q3 = median(arr[(N//2)+1:]) return Q3 - Q1 S = sorted(map(float,input().split()))
IQR = interquartile(S)