mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-18 08:44:25 +08:00
add mean absolute deviation and median absolute deviation to value metric in insights explorer
This commit is contained in:
@@ -50,6 +50,8 @@ import {
|
||||
percentile,
|
||||
sumMaxN,
|
||||
cumulativePercentage,
|
||||
meanAbsoluteDeviation,
|
||||
medianAbsoluteDeviation,
|
||||
varianceAndStandardDeviation,
|
||||
coefficientOfVariation,
|
||||
skewness,
|
||||
@@ -980,6 +982,21 @@ export const useExplorersStore = defineStore('explorers', () => {
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountMeanAbsoluteDeviation) {
|
||||
if (allSourceAmountsInDefaultCurrency.length > 0) {
|
||||
const averageSourceAmountInDefaultCurrency = totalSourceAmountSumInDefaultCurrency / allSourceAmountsInDefaultCurrency.length;
|
||||
value = Math.trunc(meanAbsoluteDeviation(allSourceAmountsInDefaultCurrency, averageSourceAmountInDefaultCurrency, item => item));
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountMedianAbsoluteDeviation) {
|
||||
if (allSourceAmountsInDefaultCurrency.length > 0) {
|
||||
allSourceAmountsInDefaultCurrency.sort((a, b) => a - b);
|
||||
const medianSourceAmountInDefaultCurrency = median(allSourceAmountsInDefaultCurrency, item => item);
|
||||
value = Math.trunc(medianAbsoluteDeviation(allSourceAmountsInDefaultCurrency, medianSourceAmountInDefaultCurrency, item => item));
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
} else if (valueMetric === TransactionExplorerValueMetric.SourceAmountVariance
|
||||
|| valueMetric === TransactionExplorerValueMetric.SourceAmountStandardDeviation
|
||||
|| valueMetric === TransactionExplorerValueMetric.SourceAmountCoefficientOfVariation
|
||||
|
||||
Reference in New Issue
Block a user