@dra2020/district-analytics 7.1.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -43
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -89649,11 +89649,8 @@ const C = __importStar(__webpack_require__(/*! ./config */ "./src/config.ts"));
|
|
|
89649
89649
|
const normalize_1 = __webpack_require__(/*! ./normalize */ "./src/normalize.ts");
|
|
89650
89650
|
// NOTE - I'm passing T.VfArray's into everything. District indices = array indices.
|
|
89651
89651
|
// NOTE - I do not (cannot) assume that the values are sorted.
|
|
89652
|
-
// TODO - Revise this.
|
|
89653
89652
|
// SCORE BIAS & COMPETITIVENESS
|
|
89654
|
-
/*
|
|
89655
|
-
|
|
89656
|
-
* ??? [statewideV] (V) = the average statewide two-party vote for Democrats
|
|
89653
|
+
/* Report fields:
|
|
89657
89654
|
|
|
89658
89655
|
* ^S# [bestS] = the Democratic seats closest to proportional
|
|
89659
89656
|
* ^S% [bestSf] = the corresponding Democratic seat share
|
|
@@ -89712,7 +89709,6 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
89712
89709
|
// Calculate additional alternate metrics for reference
|
|
89713
89710
|
const dSVpoints = inferSVpoints(Vf, VfArray, shift);
|
|
89714
89711
|
const rSVpoints = invertSVPoints(dSVpoints);
|
|
89715
|
-
// const dSVpoints = bAdvanced ? inferSVpoints(Vf, VfArray, shift) : undefined;
|
|
89716
89712
|
const TOf = bAdvanced ? calcTurnoutBias(Vf, VfArray) : undefined;
|
|
89717
89713
|
const Bs50 = bAdvanced ? estPartisanBias(dSVpoints, N) : undefined;
|
|
89718
89714
|
const Bs50f = (!(Bs50 === undefined)) ? U.trim(Bs50 / N) : undefined;
|
|
@@ -89885,44 +89881,6 @@ function scoreCompetitiveness(Cdf) {
|
|
|
89885
89881
|
return score;
|
|
89886
89882
|
}
|
|
89887
89883
|
exports.scoreCompetitiveness = scoreCompetitiveness;
|
|
89888
|
-
/* NOTE - Original version:
|
|
89889
|
-
export function scoreCompetitiveness(rawMarginal: number, rawOverall: number): number
|
|
89890
|
-
{
|
|
89891
|
-
// Normalize overall competitiveness - Raw values are in the range [0.0–1.0].
|
|
89892
|
-
// But the practical max is more like 2/3's, so unitize that range to [0.0–1.0].
|
|
89893
|
-
// Then scale the values to [0–100].
|
|
89894
|
-
const _overall = new Normalizer(rawOverall);
|
|
89895
|
-
|
|
89896
|
-
let worst = C.overallCompetitivenessRange()[C.BEG];
|
|
89897
|
-
let best = C.overallCompetitivenessRange()[C.END];
|
|
89898
|
-
|
|
89899
|
-
_overall.clip(worst, best);
|
|
89900
|
-
_overall.unitize(worst, best);
|
|
89901
|
-
_overall.rescale();
|
|
89902
|
-
|
|
89903
|
-
const ocS = _overall.normalizedNum as number;
|
|
89904
|
-
|
|
89905
|
-
|
|
89906
|
-
// Normalize marginal competitiveness
|
|
89907
|
-
const _marginal = new Normalizer(rawMarginal);
|
|
89908
|
-
|
|
89909
|
-
worst = C.marginalCompetitivenessRange()[C.BEG];
|
|
89910
|
-
best = C.marginalCompetitivenessRange()[C.END];
|
|
89911
|
-
|
|
89912
|
-
_marginal.clip(worst, best);
|
|
89913
|
-
_marginal.unitize(worst, best);
|
|
89914
|
-
_marginal.rescale();
|
|
89915
|
-
const mcS = _marginal.normalizedNum as number;
|
|
89916
|
-
|
|
89917
|
-
const mcW = C.marginalCompetitivenessWeight();
|
|
89918
|
-
const ocW = C.overallCompetitivenessWeight();
|
|
89919
|
-
|
|
89920
|
-
// Then combine the results
|
|
89921
|
-
const score = ((mcW + ocW) > 0) ? Math.round(((mcW * mcS) + (ocW * ocS)) / (mcW + ocW)) : 0;
|
|
89922
|
-
|
|
89923
|
-
return score;
|
|
89924
|
-
}
|
|
89925
|
-
*/
|
|
89926
89884
|
// CORE CAPABILITIES FROM JOHN NAGLE'S METHOD
|
|
89927
89885
|
const { erf } = __webpack_require__(/*! mathjs */ "./node_modules/mathjs/main/esm/index.js");
|
|
89928
89886
|
// console.log("erf(0.2) =", erf(0.2)); // returns 0.22270258921047847
|