The quartiles of a ranked set of data values are three points which divide the data into exactly four equal parts, each part comprising of quarter data.
- Q1 is defined as the middle number between the smallest number and the median of the data set.
- Q2 is the median of the data.
- Q3 is the middle value between the median and the highest value of the data set.
The interquartile range IQR tells us the range where the bulk of the values lie. The interquartile range is calculated by subtracting the first quartile from the third quartile. IQR = Q3 - Q1
1. Unlike range, IQR tells where the majority of data lies and is thus preferred over range.
2. IQR can be used to identify outliers in a data set.
3. Gives the central tendency of the data.
Input : 1, 19, 7, 6, 5, 9, 12, 27, 18, 2, 15 Output : 13 The data set after being sorted is 1, 2, 5, 6, 7, 9, 12, 15, 18, 19, 27 As mentioned above Q2 is the median of the data. Hence Q2 = 9 Q1 is the median of lower half, taking Q2 as pivot. So Q1 = 5 Q3 is the median of upper half talking Q2 as pivot. So Q3 = 18 Therefore IQR for given data=Q3-Q1=18-5=13 Input : 1, 3, 4, 5, 5, 6, 7, 11 Output : 3
This article is contributed by Vineet Joshi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Number of ways to obtain each numbers in range [1, b+c] by adding any two numbers in range [a, b] and [b, c]
- Generate a pair of integers from a range [L, R] whose LCM also lies within the range
- Segment Tree | Set 1 (Sum of given range)
- Count factorial numbers in a given range
- Find the smallest twins in given range
- Segmented Sieve (Print Primes in a Range)
- Print all Good numbers in given range
- Querying maximum number of divisors that a number in a given range has
- Compute (a*b)%c such that (a%c) * (b%c) can be beyond range
- Number of elements with odd factors in given range
- Count number of solutions of x^2 = 1 (mod p) in given range
- Find numbers with K odd divisors in a given range
- Find the highest occurring digit in prime numbers in a range
- Queries on the sum of prime factor counts in a range
- Maximum value in an array after m range increment operations
- Print prime numbers in a given range using C++ STL
- Queries for GCD of all numbers of an array except elements in a given range
- Perfect cubes in a range
- Find the occurrences of digit d in the range [0..n]
- Find numbers with n-divisors in a given range