|
@@ 133-142 (lines=10) @@
|
| 130 |
|
data = self.sorted_data |
| 131 |
|
|
| 132 |
|
# See: https://en.wikipedia.org/wiki/Quartile#Computing_methods |
| 133 |
|
if rounds == 1: |
| 134 |
|
return data[0] |
| 135 |
|
elif rounds % 2: # Method 3 |
| 136 |
|
n, q = rounds // 4, rounds % 4 |
| 137 |
|
if q == 1: |
| 138 |
|
return 0.75 * data[3 * n] + 0.25 * data[3 * n + 1] |
| 139 |
|
else: |
| 140 |
|
return 0.25 * data[3 * n + 1] + 0.75 * data[3 * n + 2] |
| 141 |
|
else: # Method 2 |
| 142 |
|
return statistics.median(data[rounds // 2:]) |
| 143 |
|
|
| 144 |
|
@cached_property |
| 145 |
|
def iqr(self): |
|
@@ 116-125 (lines=10) @@
|
| 113 |
|
data = self.sorted_data |
| 114 |
|
|
| 115 |
|
# See: https://en.wikipedia.org/wiki/Quartile#Computing_methods |
| 116 |
|
if rounds == 1: |
| 117 |
|
return data[0] |
| 118 |
|
elif rounds % 2: # Method 3 |
| 119 |
|
n, q = rounds // 4, rounds % 4 |
| 120 |
|
if q == 1: |
| 121 |
|
return 0.25 * data[n - 1] + 0.75 * data[n] |
| 122 |
|
else: |
| 123 |
|
return 0.75 * data[n] + 0.25 * data[n + 1] |
| 124 |
|
else: # Method 2 |
| 125 |
|
return statistics.median(data[:rounds // 2]) |
| 126 |
|
|
| 127 |
|
@cached_property |
| 128 |
|
def q3(self): |