@dra2020/dra-analytics 3.3.1 → 3.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/dra-analytics.js +18 -4
- package/dist/dra-analytics.js.map +1 -1
- package/dist/lib/all/rate.d.ts +1 -1
- package/dist/lib/all/types.d.ts +1 -1
- package/dist/lib/partisan/bias.d.ts +1 -0
- package/dist/lib/rate/dra-ratings.d.ts +1 -0
- package/lib/all/rate.ts +1 -1
- package/lib/all/types.ts +4 -1
- package/lib/partisan/bias.ts +16 -1
- package/lib/rate/dra-ratings.ts +1 -1
- package/package.json +9 -9
package/dist/dra-analytics.js
CHANGED
|
@@ -177,7 +177,7 @@ Object.defineProperty(exports, "avgSVError", ({ enumerable: true, get: function
|
|
|
177
177
|
|
|
178
178
|
// Restrict package exports
|
|
179
179
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
180
|
-
exports.popdevThreshold = exports.isAntimajoritarian = exports.ratePartisanBias = exports.rateDistrictSplitting = exports.rateCountySplitting = exports.rateSplitting = exports.ratePolsby = exports.rateReock = exports.rateCompactness = exports.rateMinorityRepresentation = exports.rateCompetitiveness = exports.rateProportionality = exports.ratePopulationDeviation = void 0;
|
|
180
|
+
exports.popdevThreshold = exports.isAntimajoritarian = exports.normalizePartisanBias = exports.ratePartisanBias = exports.rateDistrictSplitting = exports.rateCountySplitting = exports.rateSplitting = exports.ratePolsby = exports.rateReock = exports.rateCompactness = exports.rateMinorityRepresentation = exports.rateCompetitiveness = exports.rateProportionality = exports.ratePopulationDeviation = void 0;
|
|
181
181
|
var all_1 = __webpack_require__(/*! ../rate/all */ "./lib/rate/all.ts");
|
|
182
182
|
// For DRA-specific ratings
|
|
183
183
|
Object.defineProperty(exports, "ratePopulationDeviation", ({ enumerable: true, get: function () { return all_1.ratePopulationDeviation; } }));
|
|
@@ -194,6 +194,7 @@ Object.defineProperty(exports, "rateDistrictSplitting", ({ enumerable: true, get
|
|
|
194
194
|
// rateSplittingLegacy, adjustSplittingRating, rateCountySplittingLegacy, rateDistrictSplittingLegacy,
|
|
195
195
|
// For use in DRA client UI
|
|
196
196
|
Object.defineProperty(exports, "ratePartisanBias", ({ enumerable: true, get: function () { return all_1.ratePartisanBias; } }));
|
|
197
|
+
Object.defineProperty(exports, "normalizePartisanBias", ({ enumerable: true, get: function () { return all_1.normalizePartisanBias; } }));
|
|
197
198
|
Object.defineProperty(exports, "isAntimajoritarian", ({ enumerable: true, get: function () { return all_1.isAntimajoritarian; } }));
|
|
198
199
|
Object.defineProperty(exports, "popdevThreshold", ({ enumerable: true, get: function () { return all_1.popdevThreshold; } }));
|
|
199
200
|
|
|
@@ -1737,7 +1738,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1737
1738
|
return result;
|
|
1738
1739
|
};
|
|
1739
1740
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1740
|
-
exports.rangeUnearnedSeats = exports.estLocalUnearnedSeats = exports.rangeDisproportionalityAlt = exports.estLocalDisproportionalityAlt = exports.rangeDisproportionality = exports.estLocalDisproportionality = exports.rangeAsymmetry = exports.estLocalAsymmetry = exports.calcGamma = exports.calcMinimalInverseResponsiveness = exports.calcBigR = exports.calcDisproportionality = exports.calcGlobalSymmetry = exports.calcLopsidedOutcomes = exports.calcDeclination = exports.radiansToDegrees = exports.isASweep = exports.keyRVpoints = exports.calcMeanMedianDifference = exports.calcEfficiencyGap = exports.invertSVPoints = exports.inferGeometricSeatsBiasPoints = exports.estGeometricSeatsBias = exports.estVotesBias = exports.estSeatBias = exports.estPartisanBias = exports.calcTurnoutBias = exports.estUnearnedSeats = exports.calcDisproportionalityFromBest = exports.estSeatShare = exports.bestSeatShare = exports.bestSeats = void 0;
|
|
1741
|
+
exports.rangeUnearnedSeats = exports.estLocalUnearnedSeats = exports.rangeDisproportionalityAlt = exports.estLocalDisproportionalityAlt = exports.rangeDisproportionality = exports.estLocalDisproportionality = exports.rangeAsymmetry = exports.estLocalAsymmetry = exports.calcGamma = exports.calcMinimalInverseResponsiveness = exports.calcBigR = exports.calcDisproportionality = exports.calcGlobalSymmetry = exports.calcLopsidedOutcomes = exports.calcDeclination = exports.radiansToDegrees = exports.isASweep = exports.keyRVpoints = exports.calcMeanMedianDifference = exports.calcEfficiencyGapPrime = exports.calcEfficiencyGap = exports.invertSVPoints = exports.inferGeometricSeatsBiasPoints = exports.estGeometricSeatsBias = exports.estVotesBias = exports.estSeatBias = exports.estPartisanBias = exports.calcTurnoutBias = exports.estUnearnedSeats = exports.calcDisproportionalityFromBest = exports.estSeatShare = exports.bestSeatShare = exports.bestSeats = void 0;
|
|
1741
1742
|
const U = __importStar(__webpack_require__(/*! ../utils/all */ "./lib/utils/all.ts"));
|
|
1742
1743
|
const C = __importStar(__webpack_require__(/*! ../rate/dra-config */ "./lib/rate/dra-config.ts"));
|
|
1743
1744
|
const method_1 = __webpack_require__(/*! ./method */ "./lib/partisan/method.ts");
|
|
@@ -1925,6 +1926,18 @@ function calcEfficiencyGap(Vf, Sf, shareType = 0 /* Democratic */) {
|
|
|
1925
1926
|
return efficiencyGap;
|
|
1926
1927
|
}
|
|
1927
1928
|
exports.calcEfficiencyGap = calcEfficiencyGap;
|
|
1929
|
+
// For illustration purposes only
|
|
1930
|
+
// Assumes Democratic vote shares
|
|
1931
|
+
// Alternate specification with winner's bonus (R) heuristic built in:
|
|
1932
|
+
// - By convention, '+' = R bias; '-' = D bias
|
|
1933
|
+
// - If 1 <= R <= 2, EG is undefined (no/acceptable bias).
|
|
1934
|
+
function calcEfficiencyGapPrime(Vf, Sf, R) {
|
|
1935
|
+
let EG = undefined;
|
|
1936
|
+
if (R && ((R > 2) || (R < 1)))
|
|
1937
|
+
EG = (2.0 * (Vf - 0.5)) - (Sf - 0.5);
|
|
1938
|
+
return EG;
|
|
1939
|
+
}
|
|
1940
|
+
exports.calcEfficiencyGapPrime = calcEfficiencyGapPrime;
|
|
1928
1941
|
// MEAN–MEDIAN DIFFERENCE
|
|
1929
1942
|
//
|
|
1930
1943
|
// From PlanScore.org: "The mean-median difference is a party’s median vote share
|
|
@@ -2044,7 +2057,7 @@ exports.calcLopsidedOutcomes = calcLopsidedOutcomes;
|
|
|
2044
2057
|
//
|
|
2045
2058
|
// * gSym is the area of asymmetry between the two curves.
|
|
2046
2059
|
// * The choice of what base to normalize it by is somewhat arbitrary.
|
|
2047
|
-
// * We actually only infer the S–V
|
|
2060
|
+
// * We actually only infer the S–V curve over the range [0.25–0.75] <<< 101 points (not 100!)
|
|
2048
2061
|
// * But dividing by 100 normalizes the area of asymmetry to the area of the SxV unit square.
|
|
2049
2062
|
function calcGlobalSymmetry(dSVpoints, rSVpoints, S50V) {
|
|
2050
2063
|
let gSym = 0.0;
|
|
@@ -2866,7 +2879,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
2866
2879
|
return result;
|
|
2867
2880
|
};
|
|
2868
2881
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2869
|
-
exports.adjustSplittingRating = exports.rateSplittingLegacy = exports.rateDistrictSplittingLegacy = exports.countySplitWorst = exports.countySplitBest = exports.rateCountySplittingLegacy = exports.rateSplitting = exports.rateDistrictSplitting = exports.rateCountySplitting = exports.bestTarget = exports.worstMultiplier = exports.minSplitting = exports.maxSplitting = exports.rateCompactness = exports.ratePolsby = exports.rateReock = exports.rateMinorityRepresentation = exports.rateCompetitiveness = exports.ratePartisanBias = exports.isAntimajoritarian = exports.adjustDeviation = exports.extraBonus = exports.rateProportionality = exports.ratePopulationDeviation = void 0;
|
|
2882
|
+
exports.adjustSplittingRating = exports.rateSplittingLegacy = exports.rateDistrictSplittingLegacy = exports.countySplitWorst = exports.countySplitBest = exports.rateCountySplittingLegacy = exports.rateSplitting = exports.rateDistrictSplitting = exports.rateCountySplitting = exports.bestTarget = exports.worstMultiplier = exports.minSplitting = exports.maxSplitting = exports.rateCompactness = exports.ratePolsby = exports.rateReock = exports.rateMinorityRepresentation = exports.rateCompetitiveness = exports.normalizePartisanBias = exports.ratePartisanBias = exports.isAntimajoritarian = exports.adjustDeviation = exports.extraBonus = exports.rateProportionality = exports.ratePopulationDeviation = void 0;
|
|
2870
2883
|
const C = __importStar(__webpack_require__(/*! ./dra-config */ "./lib/rate/dra-config.ts"));
|
|
2871
2884
|
const normalize_1 = __webpack_require__(/*! ../rate/normalize */ "./lib/rate/normalize.ts");
|
|
2872
2885
|
const method_1 = __webpack_require__(/*! ../partisan/method */ "./lib/partisan/method.ts");
|
|
@@ -2982,6 +2995,7 @@ function normalizePartisanBias(biasPct, pctAt50) {
|
|
|
2982
2995
|
const rating = 100 * Math.exp(-Math.abs(biasPct / b));
|
|
2983
2996
|
return Math.round(rating);
|
|
2984
2997
|
}
|
|
2998
|
+
exports.normalizePartisanBias = normalizePartisanBias;
|
|
2985
2999
|
// RATE COMPETITIVENESS
|
|
2986
3000
|
// Normalize overall competitiveness - Raw values are in the range [0.0–1.0].
|
|
2987
3001
|
// But the practical max is more like 3/4's, so unitize that range to [0.0–1.0].
|