Skip to content
Snippets Groups Projects
Commit 3e4d5284 authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Added option to choose method for quartile calculation for Boxplot method.

parent 7b5b70f3
Branches
No related tags found
No related merge requests found
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
TODO: Give option to choose from multiwavelet degrees (first, last or TODO: Give option to choose from multiwavelet degrees (first, last or
highest magnitude) -> Done highest magnitude) -> Done
TODO: Change method of calculating quartiles TODO: Change method of calculating quartiles -> Done
TODO: Include overlapping cells in quartile calculation (if needed) TODO: Include overlapping cells in quartile calculation (if needed) -> Done
TODO: Determine max_value for Theoretical only over highest degree TODO: Determine max_value for Theoretical only over highest degree
-> Done (optional) -> Done (now optional)
TODO: Check if indexing in wavelets is correct TODO: Check if indexing in wavelets is correct
TODO: Combine get_cells() and _get_cells() TODO: Combine get_cells() and _get_cells()
TODO: Add TC condition to only flag cell if left-adjacent one is flagged as TODO: Add TC condition to only flag cell if left-adjacent one is flagged as
...@@ -380,7 +380,9 @@ class Boxplot(WaveletDetector): ...@@ -380,7 +380,9 @@ class Boxplot(WaveletDetector):
Flag whether outer fences should be adjusted using global mean. Flag whether outer fences should be adjusted using global mean.
extreme_outlier_only : bool extreme_outlier_only : bool
Flag whether outliers also have to be detected in neighbouring folds. Flag whether outliers also have to be detected in neighbouring folds.
folds : ndarray quantile_method : str
Method used to calculate quantiles.
fold_indices : ndarray
Array with indices for elements of each fold (including Array with indices for elements of each fold (including
overlaps). overlaps).
...@@ -405,6 +407,7 @@ class Boxplot(WaveletDetector): ...@@ -405,6 +407,7 @@ class Boxplot(WaveletDetector):
if self._mesh.num_grid_cells < self._fold_len: if self._mesh.num_grid_cells < self._fold_len:
self._fold_len = self._mesh.num_grid_cells self._fold_len = self._mesh.num_grid_cells
self._quantile_method = config.pop('quantile_method', 'weibull')
num_overlapping_cells = config.pop('num_overlapping_cells', 1) num_overlapping_cells = config.pop('num_overlapping_cells', 1)
num_folds = self._mesh.num_grid_cells//self._fold_len num_folds = self._mesh.num_grid_cells//self._fold_len
self._fold_indices = np.zeros([num_folds, self._fold_indices = np.zeros([num_folds,
...@@ -432,21 +435,12 @@ class Boxplot(WaveletDetector): ...@@ -432,21 +435,12 @@ class Boxplot(WaveletDetector):
List of indices of all detected troubled cells. List of indices of all detected troubled cells.
""" """
# Select and sort fold domains # Determine quartiles of folds
folds = coeffs[self._fold_indices] folds = coeffs[self._fold_indices]
folds.sort() first_quartiles = np.quantile(folds, 0.25, axis=1,
method=self._quantile_method)
# Determine quartile parameters third_quartiles = np.quantile(folds, 0.75, axis=1,
boundary_index = self._fold_len//4 method=self._quantile_method)
balance_factor = self._fold_len/4.0 - boundary_index
# Determine first and third quartiles
first_quartiles = (1-balance_factor) \
* folds[:, boundary_index-1] \
+ balance_factor * folds[:, boundary_index]
third_quartiles = (1-balance_factor) \
* folds[:, 3*boundary_index-1]\
+ balance_factor * folds[:, 3*boundary_index]
# Determine bounds based on quartiles of a boxplot # Determine bounds based on quartiles of a boxplot
lower_bounds = np.zeros(len(first_quartiles) + 2) lower_bounds = np.zeros(len(first_quartiles) + 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment