@dra2020/dra-analytics 3.1.4 → 3.2.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/cli/partisan.ts +5 -3
- package/dist/dra-analytics.js +24 -15
- package/dist/dra-analytics.js.map +1 -1
- package/dist/lib/partisan/bias.d.ts +2 -0
- package/dist/lib/types/partisan.d.ts +1 -0
- package/lib/partisan/all.ts +4 -2
- package/lib/partisan/bias.ts +28 -13
- package/lib/types/partisan.ts +2 -1
- package/package.json +2 -2
|
@@ -29,3 +29,5 @@ export declare function estLocalDisproportionality(Vf: number, dSVpoints: T.SVpo
|
|
|
29
29
|
export declare function rangeDisproportionality(dSVpoints: T.SVpoint[]): number;
|
|
30
30
|
export declare function estLocalDisproportionalityAlt(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined;
|
|
31
31
|
export declare function rangeDisproportionalityAlt(N: number, dSVpoints: T.SVpoint[]): number;
|
|
32
|
+
export declare function estLocalUnearnedSeats(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined;
|
|
33
|
+
export declare function rangeUnearnedSeats(N: number, dSVpoints: T.SVpoint[]): number;
|
package/lib/partisan/all.ts
CHANGED
|
@@ -34,7 +34,7 @@ import
|
|
|
34
34
|
calcGlobalSymmetry, estGeometricSeatsBias, calcDisproportionality, calcMeanMedianDifference, calcLopsidedOutcomes, calcBigR, calcGamma,
|
|
35
35
|
calcMinimalInverseResponsiveness,
|
|
36
36
|
// EXPERIMENTAL
|
|
37
|
-
estLocalAsymmetry, estLocalDisproportionality, estLocalDisproportionalityAlt
|
|
37
|
+
estLocalAsymmetry, estLocalDisproportionality, estLocalDisproportionalityAlt, estLocalUnearnedSeats
|
|
38
38
|
} from '../../lib/partisan/bias'
|
|
39
39
|
|
|
40
40
|
import
|
|
@@ -109,6 +109,7 @@ export function makePartisanScorecard(Vf: number, VfArray: T.VfArray, bLog: bool
|
|
|
109
109
|
const lSym = estLocalAsymmetry(Vf, dSVpoints, rSVpoints);
|
|
110
110
|
const lProp = estLocalDisproportionality(Vf, dSVpoints);
|
|
111
111
|
const lPropAlt = estLocalDisproportionalityAlt(Vf, N, dSVpoints);
|
|
112
|
+
const lUE = estLocalUnearnedSeats(Vf, N, dSVpoints);
|
|
112
113
|
|
|
113
114
|
const biasMeasurements: T.Bias = {
|
|
114
115
|
bestS: bestS,
|
|
@@ -158,7 +159,8 @@ export function makePartisanScorecard(Vf: number, VfArray: T.VfArray, bLog: bool
|
|
|
158
159
|
const experimentalMetrics: T.Experimental = {
|
|
159
160
|
lSym: lSym,
|
|
160
161
|
lProp: lProp,
|
|
161
|
-
lPropAlt: lPropAlt
|
|
162
|
+
lPropAlt: lPropAlt,
|
|
163
|
+
lUE: lUE
|
|
162
164
|
};
|
|
163
165
|
|
|
164
166
|
const s: T.PartisanScorecard = {
|
package/lib/partisan/bias.ts
CHANGED
|
@@ -597,7 +597,6 @@ export function rangeDisproportionalityAlt(N: number, dSVpoints: T.SVpoint[]): n
|
|
|
597
597
|
const ndPts: number = dSVpoints.length;
|
|
598
598
|
|
|
599
599
|
let tot: number = 0.0;
|
|
600
|
-
let lastBestS: number | undefined;
|
|
601
600
|
|
|
602
601
|
for (let i in dSVpoints)
|
|
603
602
|
{
|
|
@@ -605,19 +604,35 @@ export function rangeDisproportionalityAlt(N: number, dSVpoints: T.SVpoint[]): n
|
|
|
605
604
|
const bestSf = bestSeatShare(bestS, N);
|
|
606
605
|
|
|
607
606
|
tot += calcDisproportionalityFromBest(dSVpoints[i].s, bestSf);
|
|
607
|
+
}
|
|
608
608
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
609
|
+
return tot / ndPts;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Average local unearned seats from the best # of seats (closest to proportional)
|
|
613
|
+
export function estLocalUnearnedSeats(Vf: number, N: number, dSVpoints: T.SVpoint[]): number | undefined
|
|
614
|
+
{
|
|
615
|
+
const dPts = svPointRange(Vf, dSVpoints);
|
|
616
|
+
|
|
617
|
+
if (!dPts) return undefined;
|
|
618
|
+
|
|
619
|
+
const lUE: number = rangeUnearnedSeats(N, dPts);
|
|
620
|
+
|
|
621
|
+
return lUE;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
export function rangeUnearnedSeats(N: number, dSVpoints: T.SVpoint[]): number
|
|
625
|
+
{
|
|
626
|
+
const ndPts: number = dSVpoints.length;
|
|
627
|
+
|
|
628
|
+
let tot: number = 0.0;
|
|
629
|
+
|
|
630
|
+
for (let i in dSVpoints)
|
|
631
|
+
{
|
|
632
|
+
const estS: number = dSVpoints[i].s * N;
|
|
633
|
+
const bestS = bestSeats(N, dSVpoints[i].v);
|
|
634
|
+
|
|
635
|
+
tot += estUnearnedSeats(bestS, estS);
|
|
621
636
|
}
|
|
622
637
|
|
|
623
638
|
return tot / ndPts;
|
package/lib/types/partisan.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dra2020/dra-analytics",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "DRA analytics",
|
|
5
5
|
"main": "dist/dra-analytics.js",
|
|
6
|
-
"types": "./dist/all/all.d.ts",
|
|
6
|
+
"types": "./dist/lib/all/all.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "jest",
|
|
9
9
|
"build": "webpack",
|