This repository has been archived by the owner on Jun 1, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ratio buckets' aggregate analysis
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
read -d '' getRatioBucketAggregateAnalysis <<-'EOF' || true | ||
def averageIndices: | ||
. as $array | ||
| reduce range(0; length) as $index( | ||
[]; | ||
. + [ | ||
{ | ||
index: $index, | ||
value: $array[$index] | ||
} | ||
] | ||
) | ||
| map( | ||
.diff = ( | ||
.value - 0.5 | ||
| if . < 0 then . * -1 else . end | ||
) | ||
) | ||
| (map(.diff) | min) as $min | ||
| map(select(.diff == $min)) | ||
| map(.index); | ||
def averageIndexMinimum: | ||
0 as $min | ||
| .[$min]; | ||
def averageIndexMiddle: | ||
(((length - 1) / 2) | floor) as $mid | ||
| .[$mid]; | ||
def averageIndexMaximum: | ||
(length - 1) as $max | ||
| .[$max]; | ||
def getAverageIndiceRange: | ||
averageIndices | ||
| { | ||
minimum: averageIndexMinimum, | ||
middle: averageIndexMiddle, | ||
maximum: averageIndexMaximum, | ||
}; | ||
def getAverageIndiceRanges: | ||
with_entries( | ||
.value.analysis = {} | ||
| .value.analysis.index = {} | ||
| .value.analysis.index.average = (.value.normalized.cumulative | getAverageIndiceRange) | ||
); | ||
.ratios |= getAverageIndiceRanges | ||
| .occurrences |= getAverageIndiceRanges | ||
EOF | ||
|
||
jq "$getRatioBucketAggregateAnalysis" |