@dra2020/district-analytics 4.3.1 → 4.3.4
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 +35 -28
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -90063,6 +90063,7 @@ function scorePopulationDeviation(rawValue, bLegislative) {
|
|
|
90063
90063
|
const _normalizer = new normalize_1.Normalizer(rawValue);
|
|
90064
90064
|
// Raw range in not inverted (i.e., smaller is better)
|
|
90065
90065
|
const range = C.popdevRange(bLegislative);
|
|
90066
|
+
_normalizer.clip(0.0, 1.0); // Handle deviations bigger than a whole district
|
|
90066
90067
|
_normalizer.invert();
|
|
90067
90068
|
_normalizer.clip(1.0 - range[C.BEG], 1.0 - range[C.END]);
|
|
90068
90069
|
_normalizer.unitize(1.0 - range[C.BEG], 1.0 - range[C.END]);
|
|
@@ -90216,7 +90217,7 @@ function exceedsMaximumThreshold(Mf) {
|
|
|
90216
90217
|
return Mf > threshold;
|
|
90217
90218
|
}
|
|
90218
90219
|
function calcProportionalDistricts(proportion, nDistricts) {
|
|
90219
|
-
// TODO -
|
|
90220
|
+
// TODO - Maybe bump up to get a statewide proportion on the bubble to rate one district?
|
|
90220
90221
|
const roundUp = 0.0;
|
|
90221
90222
|
const fractional = proportion * nDistricts;
|
|
90222
90223
|
const integral = Math.round(fractional + roundUp);
|
|
@@ -90365,14 +90366,14 @@ const normalize_1 = __webpack_require__(/*! ./normalize */ "./src/normalize.ts")
|
|
|
90365
90366
|
* S# [estS] (S_V) = the estimated Democratic seats, using seat probabilities
|
|
90366
90367
|
* S% [estSf] = the estimated Democratic seat share fraction, calculated as S# / N
|
|
90367
90368
|
|
|
90368
|
-
* BS_50 [bS50] = Seat bias as a fraction of N
|
|
90369
|
-
* 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
|
|
90370
90371
|
* decl [decl] = Declination
|
|
90371
|
-
* GS [gSym] = Global symmetry
|
|
90372
|
+
* GS [gSym] = Global symmetry
|
|
90372
90373
|
|
|
90373
90374
|
* EG [EG] = Efficiency gap as a fraction
|
|
90374
|
-
* BS_V [bSV] = Seats bias @ <V> (geometric)
|
|
90375
|
-
* PR [prop] = Disproportionality
|
|
90375
|
+
* BS_V [bSV] = Seats bias @ <V> (geometric)
|
|
90376
|
+
* PR [prop] = Disproportionality
|
|
90376
90377
|
* MM [mMs] = Mean – median difference using statewide Vf
|
|
90377
90378
|
* TO [tOf] = Turnout bias
|
|
90378
90379
|
* MM' [mMd] = Mean – median difference using average district v
|
|
@@ -90416,7 +90417,7 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
90416
90417
|
const bias = estBias(estSf, bestSf);
|
|
90417
90418
|
const biasScore = scorebias(bias, Vf, estSf);
|
|
90418
90419
|
const unearnedS = estUnearnedSeats(bestS, estS);
|
|
90419
|
-
const impactScore = scoreImpact(unearnedS, Vf, N);
|
|
90420
|
+
const impactScore = scoreImpact(unearnedS, Vf, estSf, N);
|
|
90420
90421
|
// Calculate additional alternate metrics for reference
|
|
90421
90422
|
// NOTE - Use the uncompressed seat probability function
|
|
90422
90423
|
const inferredSVpoints = bAlternateMetrics ? inferSVpoints(Vf, VfArray, shift) : undefined;
|
|
@@ -90439,7 +90440,8 @@ function scorePartisan(Vf, VfArray, options) {
|
|
|
90439
90440
|
const rD = (!bConstrained || bAlternateMetrics) ? estResponsiveDistricts(VfArray) : undefined;
|
|
90440
90441
|
const rDf = bAlternateMetrics ? estResponsiveDistrictsShare(rD, N) : undefined;
|
|
90441
90442
|
const Cn = countCompetitiveDistricts(VfArray);
|
|
90442
|
-
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;
|
|
90443
90445
|
const cDf = estCompetitiveDistrictsShare(cD, N);
|
|
90444
90446
|
const Mrange = findMarginalDistricts(Vf, VfArray, N);
|
|
90445
90447
|
const Md = estMarginalCompetitiveDistricts(Mrange, VfArray);
|
|
@@ -90547,22 +90549,27 @@ function adjustBias(Vf, bias, extra) {
|
|
|
90547
90549
|
}
|
|
90548
90550
|
exports.adjustBias = adjustBias;
|
|
90549
90551
|
// Normalize unearned seats
|
|
90550
|
-
function scoreImpact(rawUE, Vf, N) {
|
|
90551
|
-
|
|
90552
|
-
|
|
90553
|
-
|
|
90554
|
-
|
|
90555
|
-
|
|
90556
|
-
|
|
90557
|
-
|
|
90558
|
-
|
|
90559
|
-
|
|
90560
|
-
|
|
90561
|
-
|
|
90562
|
-
|
|
90563
|
-
|
|
90564
|
-
|
|
90565
|
-
|
|
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
|
+
}
|
|
90566
90573
|
}
|
|
90567
90574
|
exports.scoreImpact = scoreImpact;
|
|
90568
90575
|
function isAntimajoritarian(Vf, Sf) {
|
|
@@ -91209,13 +91216,13 @@ function printPartisanScorecardRow(xx, name, N, Vf, s) {
|
|
|
91209
91216
|
exports.printPartisanScorecardRow = printPartisanScorecardRow;
|
|
91210
91217
|
// Generate partisan details (Table 1)
|
|
91211
91218
|
function printPartisanDetailsHeader() {
|
|
91212
|
-
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');
|
|
91213
91220
|
}
|
|
91214
91221
|
exports.printPartisanDetailsHeader = printPartisanDetailsHeader;
|
|
91215
91222
|
function printPartisanDetailsRow(xx, name, N, Vf, s) {
|
|
91216
|
-
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
|
|
91217
91224
|
s.bias.prop, // Lower-gamma
|
|
91218
|
-
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
|
|
91219
91226
|
);
|
|
91220
91227
|
}
|
|
91221
91228
|
exports.printPartisanDetailsRow = printPartisanDetailsRow;
|
|
@@ -91288,7 +91295,7 @@ function scorePlan(p, overridesJSON) {
|
|
|
91288
91295
|
// PARTISAN ("fair") subcategories - bias, impact, & competitiveness (plus lots of supporting measures)
|
|
91289
91296
|
const options = {
|
|
91290
91297
|
alternates: true,
|
|
91291
|
-
constrained:
|
|
91298
|
+
constrained: false,
|
|
91292
91299
|
shift: 0 /* Proportional */
|
|
91293
91300
|
};
|
|
91294
91301
|
const pS = partisan_1.scorePartisan(p.partisanProfile.statewideVf, p.partisanProfile.vfArray, options);
|