From 124dfa934a1ff8d821e4d9d6dad236d14adbffda Mon Sep 17 00:00:00 2001 From: Mahdi Date: Sun, 29 Sep 2024 15:47:05 +0330 Subject: [PATCH] Bring back different damping factors --- src/utils/mathematical-logic/index.ts | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/utils/mathematical-logic/index.ts b/src/utils/mathematical-logic/index.ts index 69ae48c..593da84 100644 --- a/src/utils/mathematical-logic/index.ts +++ b/src/utils/mathematical-logic/index.ts @@ -39,22 +39,22 @@ export const toFixedNumber = (num: number, digits: number) => { }; const isRankingUseful = (ranking: number[]) => { - // const numOfZeros = ranking.filter( - // (score) => toFixedNumber(score, 3) <= 0.001, - // ).length; + const numOfZeros = ranking.filter( + (score) => toFixedNumber(score, 3) <= 0.001, + ).length; - // if (numOfZeros > 0) return false; + if (numOfZeros > 0) return false; - // const sortedRanking = [...ranking].sort(); + const sortedRanking = [...ranking].sort(); - // let median = sortedRanking[Math.floor(sortedRanking.length / 2)]; - // if (sortedRanking.length % 2 === 0) { - // median = - // (median + sortedRanking[Math.floor(sortedRanking.length / 2) - 1]) / 2; - // } - // const max = sortedRanking[sortedRanking.length - 1]; + let median = sortedRanking[Math.floor(sortedRanking.length / 2)]; + if (sortedRanking.length % 2 === 0) { + median = + (median + sortedRanking[Math.floor(sortedRanking.length / 2) - 1]) / 2; + } + const max = sortedRanking[sortedRanking.length - 1]; - // if (max / median > 10) return false; + if (max / median > 10) return false; return true; }; @@ -66,11 +66,11 @@ function cloneArray(a: T): T { } export const getRankingForSetOfDampingFactors = (input: number[][]) => { - const dampingFactors = [0.85]; - // const dampingFactors = [ - // 1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, - // 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0, - // ]; + // const dampingFactors = [0.85]; + const dampingFactors = [ + 1, 0.95, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65, 0.6, 0.55, 0.5, 0.45, 0.4, 0.35, + 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0, + ]; // const dampingFactors = [ // 0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, // 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 1,