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