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 @@
TODO: Give option to choose from multiwavelet degrees (first, last or
highest magnitude) -> Done
TODO: Change method of calculating quartiles
TODO: Include overlapping cells in quartile calculation (if needed)
TODO: Change method of calculating quartiles -> Done
TODO: Include overlapping cells in quartile calculation (if needed) -> Done
TODO: Determine max_value for Theoretical only over highest degree
-> Done (optional)
-> Done (now optional)
TODO: Check if indexing in wavelets is correct
TODO: Combine get_cells() and _get_cells()
TODO: Add TC condition to only flag cell if left-adjacent one is flagged as
......@@ -380,7 +380,9 @@ class Boxplot(WaveletDetector):
Flag whether outer fences should be adjusted using global mean.
extreme_outlier_only : bool
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
overlaps).
......@@ -405,6 +407,7 @@ class Boxplot(WaveletDetector):
if self._mesh.num_grid_cells < self._fold_len:
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_folds = self._mesh.num_grid_cells//self._fold_len
self._fold_indices = np.zeros([num_folds,
......@@ -432,21 +435,12 @@ class Boxplot(WaveletDetector):
List of indices of all detected troubled cells.
"""
# Select and sort fold domains
# Determine quartiles of folds
folds = coeffs[self._fold_indices]
folds.sort()
# Determine quartile parameters
boundary_index = self._fold_len//4
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]
first_quartiles = np.quantile(folds, 0.25, axis=1,
method=self._quantile_method)
third_quartiles = np.quantile(folds, 0.75, axis=1,
method=self._quantile_method)
# Determine bounds based on quartiles of a boxplot
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