@dra2020/district-analytics 4.3.2 → 4.3.5
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 +34 -28
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -90217,7 +90217,7 @@ function exceedsMaximumThreshold(Mf) {
|
|
|
90217
90217
|
return Mf > threshold;
|
|
90218
90218
|
}
|
|
90219
90219
|
function calcProportionalDistricts(proportion, nDistricts) {
|
|
90220
|
-
// TODO -
|
|
90220
|
+
// TODO - Maybe bump up to get a statewide proportion on the bubble to rate one district?
|
|
90221
90221
|
const roundUp = 0.0;
|
|
90222
90222
|
const fractional = proportion * nDistricts;
|
|
90223
90223
|
const integral = Math.round(fractional + roundUp);
|
|
@@ -90366,14 +90366,14 @@ const normalize_1 = __webpack_require__(/*! ./normalize */ "./src/normalize.ts")
|
|
|
90366
90366
|
* S# [estS] (S_V) = the estimated Democratic seats, using seat probabilities
|
|
90367
90367
|
* S% [estSf] = the estimated Democratic seat share fraction, calculated as S# / N
|
|
90368
90368
|
|
|
90369
|
-
* BS_50 [bS50] = Seat bias as a fraction of N
|
|
90370
|
-
* BV_50 [bV50] = Votes bias as a fraction
|
|
90369
|
+
* BS_50 [bS50] = Seat bias as a fraction of N
|
|
90370
|
+
* BV_50 [bV50] = Votes bias as a fraction
|
|
90371
90371
|
* decl [decl] = Declination
|
|
90372
|
-
* GS [gSym] = Global symmetry
|
|
90372
|
+
* GS [gSym] = Global symmetry
|
|
90373
90373
|
|
|
90374
90374
|
* EG [EG] = Efficiency gap as a fraction
|
|
90375
|
-
* BS_V [bSV] = Seats bias @ <V> (geometric)
|
|
90376
|
-
* PR [prop] = Disproportionality
|
|
90375
|
+
* BS_V [bSV] = Seats bias @ <V> (geometric)
|
|
90376
|
+
* PR [prop] = Disproportionality
|
|
90377
90377
|
* MM [mMs] = Mean – median difference using statewide Vf
|
|
90378
90378
|
* TO [tOf] = Turnout bias
|
|
90379
90379
|
* MM' [mMd] = Mean – median difference using average district v
|
|
@@ -90417,7 +90417,7 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
90417
90417
|
const bias = estBias(estSf, bestSf);
|
|
90418
90418
|
const biasScore = scorebias(bias, Vf, estSf);
|
|
90419
90419
|
const unearnedS = estUnearnedSeats(bestS, estS);
|
|
90420
|
-
const impactScore = scoreImpact(unearnedS, Vf, N);
|
|
90420
|
+
const impactScore = scoreImpact(unearnedS, Vf, estSf, N);
|
|
90421
90421
|
// Calculate additional alternate metrics for reference
|
|
90422
90422
|
// NOTE - Use the uncompressed seat probability function
|
|
90423
90423
|
const inferredSVpoints = bAlternateMetrics ? inferSVpoints(Vf, VfArray, shift) : undefined;
|
|
@@ -90440,7 +90440,8 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
90440
90440
|
const rD = (!bConstrained || bAlternateMetrics) ? estResponsiveDistricts(VfArray) : undefined;
|
|
90441
90441
|
const rDf = bAlternateMetrics ? estResponsiveDistrictsShare(rD, N) : undefined;
|
|
90442
90442
|
const Cn = countCompetitiveDistricts(VfArray);
|
|
90443
|
-
const cD =
|
|
90443
|
+
const cD = estCompetitiveDistricts(VfArray); // NOTE - Cd by definition uses a more narrow probability distribution vs. Rd
|
|
90444
|
+
// const cD = bConstrained ? estCompetitiveDistricts(VfArray) : rD as number;
|
|
90444
90445
|
const cDf = estCompetitiveDistrictsShare(cD, N);
|
|
90445
90446
|
const Mrange = findMarginalDistricts(Vf, VfArray, N);
|
|
90446
90447
|
const Md = estMarginalCompetitiveDistricts(Mrange, VfArray);
|
|
@@ -90548,22 +90549,27 @@ function adjustBias(Vf, bias, extra) {
|
|
|
90548
90549
|
}
|
|
90549
90550
|
exports.adjustBias = adjustBias;
|
|
90550
90551
|
// Normalize unearned seats
|
|
90551
|
-
function scoreImpact(rawUE, Vf, N) {
|
|
90552
|
-
|
|
90553
|
-
|
|
90554
|
-
|
|
90555
|
-
|
|
90556
|
-
|
|
90557
|
-
|
|
90558
|
-
|
|
90559
|
-
|
|
90560
|
-
|
|
90561
|
-
|
|
90562
|
-
|
|
90563
|
-
|
|
90564
|
-
|
|
90565
|
-
|
|
90566
|
-
|
|
90552
|
+
function scoreImpact(rawUE, Vf, Sf, N) {
|
|
90553
|
+
if (isAntimajoritarian(Vf, Sf)) {
|
|
90554
|
+
return 0;
|
|
90555
|
+
}
|
|
90556
|
+
else {
|
|
90557
|
+
// Adjust impact to incorporate an acceptable winner's bonus based on Vf
|
|
90558
|
+
const extra = extraBonus(Vf);
|
|
90559
|
+
const adjustedBias = adjustBias(Vf, rawUE / N, extra);
|
|
90560
|
+
const adjustedImpact = adjustedBias * N;
|
|
90561
|
+
// Then normalize
|
|
90562
|
+
const _normalizer = new normalize_1.Normalizer(adjustedImpact);
|
|
90563
|
+
const worst = C.unearnedThreshold();
|
|
90564
|
+
const best = 0.0;
|
|
90565
|
+
_normalizer.positive();
|
|
90566
|
+
_normalizer.clip(worst, best);
|
|
90567
|
+
_normalizer.unitize(worst, best);
|
|
90568
|
+
_normalizer.invert();
|
|
90569
|
+
_normalizer.rescale();
|
|
90570
|
+
const score = _normalizer.normalizedNum;
|
|
90571
|
+
return score;
|
|
90572
|
+
}
|
|
90567
90573
|
}
|
|
90568
90574
|
exports.scoreImpact = scoreImpact;
|
|
90569
90575
|
function isAntimajoritarian(Vf, Sf) {
|
|
@@ -91210,13 +91216,13 @@ function printPartisanScorecardRow(xx, name, N, Vf, s) {
|
|
|
91210
91216
|
exports.printPartisanScorecardRow = printPartisanScorecardRow;
|
|
91211
91217
|
// Generate partisan details (Table 1)
|
|
91212
91218
|
function printPartisanDetailsHeader() {
|
|
91213
|
-
console.log('XX, <V>, S(<V>), S50V, V50S, Decl, B_G, EG, Beta, l-gamma, mM, TO, mM\', LO, R, r, Zeta');
|
|
91219
|
+
console.log('XX, <V>, S(<V>), S50V, V50S, Decl, B_G, EG, Beta, l-gamma, mM, TO, mM\', LO, Rd, R, r, Zeta');
|
|
91214
91220
|
}
|
|
91215
91221
|
exports.printPartisanDetailsHeader = printPartisanDetailsHeader;
|
|
91216
91222
|
function printPartisanDetailsRow(xx, name, N, Vf, s) {
|
|
91217
|
-
console.log('%s, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f', xx, Vf, s.bias.estSf, s.bias.bS50, s.bias.bV50, s.bias.decl, s.bias.gSym, s.bias.eG, s.bias.bSV, // Beta
|
|
91223
|
+
console.log('%s, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f', xx, Vf, s.bias.estSf, s.bias.bS50, s.bias.bV50, s.bias.decl, s.bias.gSym, s.bias.eG, s.bias.bSV, // Beta
|
|
91218
91224
|
s.bias.prop, // Lower-gamma
|
|
91219
|
-
s.bias.mMs, s.bias.tOf, s.bias.mMd, s.bias.lO, s.competitiveness.bigR, s.competitiveness.littleR, s.competitiveness.mIR // Zeta
|
|
91225
|
+
s.bias.mMs, s.bias.tOf, s.bias.mMd, s.bias.lO, s.competitiveness.rD, s.competitiveness.bigR, s.competitiveness.littleR, s.competitiveness.mIR // Zeta
|
|
91220
91226
|
);
|
|
91221
91227
|
}
|
|
91222
91228
|
exports.printPartisanDetailsRow = printPartisanDetailsRow;
|
|
@@ -91289,7 +91295,7 @@ function scorePlan(p, overridesJSON) {
|
|
|
91289
91295
|
// PARTISAN ("fair") subcategories - bias, impact, & competitiveness (plus lots of supporting measures)
|
|
91290
91296
|
const options = {
|
|
91291
91297
|
alternates: true,
|
|
91292
|
-
constrained:
|
|
91298
|
+
constrained: false,
|
|
91293
91299
|
shift: 0 /* Proportional */
|
|
91294
91300
|
};
|
|
91295
91301
|
const pS = partisan_1.scorePartisan(p.partisanProfile.statewideVf, p.partisanProfile.vfArray, options);
|