mergeron 2024.738973.0__py3-none-any.whl → 2024.739079.9__py3-none-any.whl
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.
Potentially problematic release.
This version of mergeron might be problematic. Click here for more details.
- mergeron/__init__.py +28 -3
- mergeron/core/__init__.py +2 -77
- mergeron/core/damodaran_margin_data.py +66 -52
- mergeron/core/excel_helper.py +32 -37
- mergeron/core/ftc_merger_investigations_data.py +66 -35
- mergeron/core/guidelines_boundaries.py +261 -234
- mergeron/core/guidelines_boundary_functions.py +182 -27
- mergeron/core/guidelines_boundary_functions_extra.py +17 -14
- mergeron/core/proportions_tests.py +2 -4
- mergeron/core/pseudorandom_numbers.py +6 -11
- mergeron/data/__init__.py +3 -0
- mergeron/data/damodaran_margin_data.xls +0 -0
- mergeron/data/damodaran_margin_data_dict.msgpack +0 -0
- mergeron/{jinja_LaTex_templates/setup_tikz_tables.tex.jinja2 → data/jinja2_LaTeX_templates/setup_tikz_tables.tex} +45 -50
- mergeron/demo/__init__.py +3 -0
- mergeron/demo/visualize_empirical_margin_distribution.py +88 -0
- mergeron/ext/__init__.py +2 -4
- mergeron/ext/tol_colors.py +3 -3
- mergeron/gen/__init__.py +53 -46
- mergeron/gen/_data_generation_functions.py +28 -93
- mergeron/gen/data_generation.py +20 -24
- mergeron/gen/{investigations_stats.py → enforcement_stats.py} +59 -57
- mergeron/gen/market_sample.py +6 -10
- mergeron/gen/upp_tests.py +29 -26
- mergeron-2024.739079.9.dist-info/METADATA +109 -0
- mergeron-2024.739079.9.dist-info/RECORD +36 -0
- mergeron/core/InCommon RSA Server CA cert chain.pem +0 -68
- mergeron-2024.738973.0.dist-info/METADATA +0 -108
- mergeron-2024.738973.0.dist-info/RECORD +0 -32
- /mergeron/{core → data}/ftc_invdata.msgpack +0 -0
- /mergeron/{jinja_LaTex_templates → data/jinja2_LaTeX_templates}/clrrate_cis_summary_table_template.tex.jinja2 +0 -0
- /mergeron/{jinja_LaTex_templates → data/jinja2_LaTeX_templates}/ftcinvdata_byhhianddelta_table_template.tex.jinja2 +0 -0
- /mergeron/{jinja_LaTex_templates → data/jinja2_LaTeX_templates}/ftcinvdata_summary_table_template.tex.jinja2 +0 -0
- /mergeron/{jinja_LaTex_templates → data/jinja2_LaTeX_templates}/ftcinvdata_summarypaired_table_template.tex.jinja2 +0 -0
- /mergeron/{jinja_LaTex_templates → data/jinja2_LaTeX_templates}/mergeron.cls +0 -0
- /mergeron/{jinja_LaTex_templates → data/jinja2_LaTeX_templates}/mergeron_table_collection_template.tex.jinja2 +0 -0
- {mergeron-2024.738973.0.dist-info → mergeron-2024.739079.9.dist-info}/WHEEL +0 -0
|
@@ -1,21 +1,39 @@
|
|
|
1
1
|
import decimal
|
|
2
|
-
from
|
|
3
|
-
from typing import Any, Literal
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Any, Literal, TypedDict
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from mpmath import mp, mpf # type: ignore
|
|
7
7
|
from numpy.typing import NDArray
|
|
8
8
|
|
|
9
|
-
from .. import
|
|
10
|
-
from . import GuidelinesBoundary
|
|
11
|
-
|
|
12
|
-
__version__ = version(_PKG_NAME)
|
|
9
|
+
from .. import VERSION # noqa: TID252
|
|
13
10
|
|
|
11
|
+
__version__ = VERSION
|
|
14
12
|
|
|
15
13
|
mp.prec = 80
|
|
16
14
|
mp.trap_complex = True
|
|
17
15
|
|
|
18
16
|
|
|
17
|
+
class ShareRatioBoundaryKeywords(TypedDict, total=False):
|
|
18
|
+
"""Keyword arguments for functions generating share ratio boundaries."""
|
|
19
|
+
|
|
20
|
+
recapture_form: Literal["inside-out", "proportional"]
|
|
21
|
+
prec: int
|
|
22
|
+
agg_method: Literal["arithmetic mean", "geometric mean", "distance"]
|
|
23
|
+
weighting: Literal["own-share", "cross-product-share", None]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class GuidelinesBoundary:
|
|
28
|
+
"""Output of a Guidelines boundary function."""
|
|
29
|
+
|
|
30
|
+
coordinates: NDArray[np.float64]
|
|
31
|
+
"""Market-share pairs as Cartesian coordinates of points on the boundary."""
|
|
32
|
+
|
|
33
|
+
area: float
|
|
34
|
+
"""Area under the boundary."""
|
|
35
|
+
|
|
36
|
+
|
|
19
37
|
def dh_area(_dh_val: float = 0.01, /, *, prec: int = 9) -> float:
|
|
20
38
|
R"""
|
|
21
39
|
Area under the ΔHHI boundary.
|
|
@@ -57,13 +75,150 @@ def dh_area(_dh_val: float = 0.01, /, *, prec: int = 9) -> float:
|
|
|
57
75
|
)
|
|
58
76
|
|
|
59
77
|
|
|
78
|
+
def hhi_delta_boundary(
|
|
79
|
+
_dh_val: float = 0.01, /, *, prec: int = 5
|
|
80
|
+
) -> GuidelinesBoundary:
|
|
81
|
+
"""
|
|
82
|
+
Generate the list of share combination on the ΔHHI boundary.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
_dh_val:
|
|
87
|
+
Merging-firms' ΔHHI bound.
|
|
88
|
+
prec
|
|
89
|
+
Number of decimal places for rounding reported shares.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
Array of share-pairs, area under boundary.
|
|
94
|
+
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
_dh_val = mpf(f"{_dh_val}")
|
|
98
|
+
_s_naught = 1 / 2 * (1 - mp.sqrt(1 - 2 * _dh_val))
|
|
99
|
+
_s_mid = mp.sqrt(_dh_val / 2)
|
|
100
|
+
|
|
101
|
+
_dh_step_sz = mp.power(10, -6)
|
|
102
|
+
_s_1 = np.array(mp.arange(_s_mid, _s_naught - mp.eps, -_dh_step_sz))
|
|
103
|
+
_s_2 = _dh_val / (2 * _s_1)
|
|
104
|
+
|
|
105
|
+
# Boundary points
|
|
106
|
+
_dh_half = np.vstack((
|
|
107
|
+
np.column_stack((_s_1, _s_2)),
|
|
108
|
+
np.array([(mpf("0.0"), mpf("1.0"))]),
|
|
109
|
+
))
|
|
110
|
+
_dh_bdry_pts = np.vstack((np.flip(_dh_half, 0), np.flip(_dh_half[1:], 1)))
|
|
111
|
+
|
|
112
|
+
_s_1_pts, _s_2_pts = np.split(_dh_bdry_pts, 2, axis=1)
|
|
113
|
+
return GuidelinesBoundary(
|
|
114
|
+
np.column_stack((
|
|
115
|
+
np.array(_s_1_pts, np.float64),
|
|
116
|
+
np.array(_s_2_pts, np.float64),
|
|
117
|
+
)),
|
|
118
|
+
dh_area(_dh_val, prec=prec),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def hhi_pre_contrib_boundary(
|
|
123
|
+
_hhi_contrib: float = 0.03125, /, *, prec: int = 5
|
|
124
|
+
) -> GuidelinesBoundary:
|
|
125
|
+
"""
|
|
126
|
+
Share combinations on the premerger HHI contribution boundary.
|
|
127
|
+
|
|
128
|
+
Parameters
|
|
129
|
+
----------
|
|
130
|
+
_hhi_contrib:
|
|
131
|
+
Merging-firms' pre-merger HHI contribution bound.
|
|
132
|
+
prec
|
|
133
|
+
Number of decimal places for rounding reported shares.
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
Array of share-pairs, area under boundary.
|
|
138
|
+
|
|
139
|
+
"""
|
|
140
|
+
_hhi_contrib = mpf(f"{_hhi_contrib}")
|
|
141
|
+
_s_mid = mp.sqrt(_hhi_contrib / 2)
|
|
142
|
+
|
|
143
|
+
_bdry_step_sz = mp.power(10, -prec)
|
|
144
|
+
# Range-limit is 0 less a step, which is -1 * step-size
|
|
145
|
+
_s_1 = np.array(mp.arange(_s_mid, -_bdry_step_sz, -_bdry_step_sz), np.float64)
|
|
146
|
+
_s_2 = np.sqrt(_hhi_contrib - _s_1**2).astype(np.float64)
|
|
147
|
+
_bdry_pts_mid = np.column_stack((_s_1, _s_2))
|
|
148
|
+
return GuidelinesBoundary(
|
|
149
|
+
np.vstack((np.flip(_bdry_pts_mid, 0), np.flip(_bdry_pts_mid[1:], 1))),
|
|
150
|
+
round(float(mp.pi * _hhi_contrib / 4), prec),
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def combined_share_boundary(
|
|
155
|
+
_s_intcpt: float = 0.0625, /, *, prec: int = 10
|
|
156
|
+
) -> GuidelinesBoundary:
|
|
157
|
+
"""
|
|
158
|
+
Share combinations on the merging-firms' combined share boundary.
|
|
159
|
+
|
|
160
|
+
Assumes symmetric merging-firm margins. The combined-share is
|
|
161
|
+
congruent to the post-merger HHI contribution boundary, as the
|
|
162
|
+
post-merger HHI bound is the square of the combined-share bound.
|
|
163
|
+
|
|
164
|
+
Parameters
|
|
165
|
+
----------
|
|
166
|
+
_s_intcpt:
|
|
167
|
+
Merging-firms' combined share.
|
|
168
|
+
prec
|
|
169
|
+
Number of decimal places for rounding reported shares.
|
|
170
|
+
|
|
171
|
+
Returns
|
|
172
|
+
-------
|
|
173
|
+
Array of share-pairs, area under boundary.
|
|
174
|
+
|
|
175
|
+
"""
|
|
176
|
+
_s_intcpt = mpf(f"{_s_intcpt}")
|
|
177
|
+
_s_mid = _s_intcpt / 2
|
|
178
|
+
|
|
179
|
+
_s1_pts = (0, _s_mid, _s_intcpt)
|
|
180
|
+
return GuidelinesBoundary(
|
|
181
|
+
np.column_stack((
|
|
182
|
+
np.array(_s1_pts, np.float64),
|
|
183
|
+
np.array(_s1_pts[::-1], np.float64),
|
|
184
|
+
)),
|
|
185
|
+
round(float(_s_intcpt * _s_mid), prec),
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def hhi_post_contrib_boundary(
|
|
190
|
+
_hhi_contrib: float = 0.800, /, *, prec: int = 10
|
|
191
|
+
) -> GuidelinesBoundary:
|
|
192
|
+
"""
|
|
193
|
+
Share combinations on the postmerger HHI contribution boundary.
|
|
194
|
+
|
|
195
|
+
The post-merger HHI contribution boundary is identical to the
|
|
196
|
+
combined-share boundary.
|
|
197
|
+
|
|
198
|
+
Parameters
|
|
199
|
+
----------
|
|
200
|
+
_hhi_contrib:
|
|
201
|
+
Merging-firms' pre-merger HHI contribution bound.
|
|
202
|
+
prec
|
|
203
|
+
Number of decimal places for rounding reported shares.
|
|
204
|
+
|
|
205
|
+
Returns
|
|
206
|
+
-------
|
|
207
|
+
Array of share-pairs, area under boundary.
|
|
208
|
+
|
|
209
|
+
"""
|
|
210
|
+
return combined_share_boundary(np.sqrt(_hhi_contrib), prec=prec)
|
|
211
|
+
|
|
212
|
+
|
|
60
213
|
def shrratio_boundary_wtd_avg(
|
|
61
214
|
_delta_star: float = 0.075,
|
|
62
|
-
_r_val: float = 0.
|
|
215
|
+
_r_val: float = 0.85,
|
|
63
216
|
/,
|
|
64
217
|
*,
|
|
65
|
-
agg_method: Literal[
|
|
66
|
-
|
|
218
|
+
agg_method: Literal[
|
|
219
|
+
"arithmetic mean", "geometric mean", "distance"
|
|
220
|
+
] = "arithmetic mean",
|
|
221
|
+
weighting: Literal["own-share", "cross-product-share", None] = "own-share",
|
|
67
222
|
recapture_form: Literal["inside-out", "proportional"] = "inside-out",
|
|
68
223
|
prec: int = 5,
|
|
69
224
|
) -> GuidelinesBoundary:
|
|
@@ -77,7 +232,7 @@ def shrratio_boundary_wtd_avg(
|
|
|
77
232
|
_r_val
|
|
78
233
|
recapture ratio
|
|
79
234
|
agg_method
|
|
80
|
-
Whether "arithmetic", "geometric", or "distance".
|
|
235
|
+
Whether "arithmetic mean", "geometric mean", or "distance".
|
|
81
236
|
weighting
|
|
82
237
|
Whether "own-share" or "cross-product-share" (or None for simple, unweighted average).
|
|
83
238
|
recapture_form
|
|
@@ -253,20 +408,20 @@ def shrratio_boundary_wtd_avg(
|
|
|
253
408
|
# Area under boundary
|
|
254
409
|
_gbdry_area_total = float(2 * _gbd_prtlarea - mp.power(_s_mid, "2"))
|
|
255
410
|
|
|
256
|
-
_gbdry_points = np.
|
|
411
|
+
_gbdry_points = np.vstack((_gbdry_points, (mpf("0.0"), _s_intcpt))).astype(
|
|
257
412
|
np.float64
|
|
258
413
|
)
|
|
259
414
|
|
|
260
415
|
# Points defining boundary to point-of-symmetry
|
|
261
416
|
return GuidelinesBoundary(
|
|
262
|
-
np.
|
|
417
|
+
np.vstack((np.flip(_gbdry_points, 0), np.flip(_gbdry_points[1:], 1))),
|
|
263
418
|
round(float(_gbdry_area_total), prec),
|
|
264
419
|
)
|
|
265
420
|
|
|
266
421
|
|
|
267
422
|
def shrratio_boundary_xact_avg(
|
|
268
423
|
_delta_star: float = 0.075,
|
|
269
|
-
_r_val: float = 0.
|
|
424
|
+
_r_val: float = 0.85,
|
|
270
425
|
/,
|
|
271
426
|
*,
|
|
272
427
|
recapture_form: Literal["inside-out", "proportional"] = "inside-out",
|
|
@@ -396,7 +551,7 @@ def shrratio_boundary_xact_avg(
|
|
|
396
551
|
_gbdry_points_inner = np.column_stack((_s_1, _s_2))
|
|
397
552
|
_gbdry_points_end = np.array([(mpf("0.0"), _s_intcpt)], np.float64)
|
|
398
553
|
|
|
399
|
-
_gbdry_points = np.
|
|
554
|
+
_gbdry_points = np.vstack((
|
|
400
555
|
_gbdry_points_end,
|
|
401
556
|
np.flip(_gbdry_points_inner, 0),
|
|
402
557
|
_gbdry_points_start,
|
|
@@ -425,7 +580,7 @@ def shrratio_boundary_xact_avg(
|
|
|
425
580
|
|
|
426
581
|
def shrratio_boundary_min(
|
|
427
582
|
_delta_star: float = 0.075,
|
|
428
|
-
_r_val: float = 0.
|
|
583
|
+
_r_val: float = 0.85,
|
|
429
584
|
/,
|
|
430
585
|
*,
|
|
431
586
|
recapture_form: str = "inside-out",
|
|
@@ -491,7 +646,7 @@ def shrratio_boundary_min(
|
|
|
491
646
|
|
|
492
647
|
|
|
493
648
|
def shrratio_boundary_max(
|
|
494
|
-
_delta_star: float = 0.075, _r_val: float = 0.
|
|
649
|
+
_delta_star: float = 0.075, _r_val: float = 0.85, /, *, prec: int = 10
|
|
495
650
|
) -> GuidelinesBoundary:
|
|
496
651
|
"""
|
|
497
652
|
Share combinations on the minimum GUPPI boundary with symmetric
|
|
@@ -537,8 +692,8 @@ def _shrratio_boundary_intcpt(
|
|
|
537
692
|
/,
|
|
538
693
|
*,
|
|
539
694
|
recapture_form: Literal["inside-out", "proportional"],
|
|
540
|
-
agg_method: Literal["arithmetic", "geometric", "distance"],
|
|
541
|
-
weighting: Literal["cross-product-share", "own-share"
|
|
695
|
+
agg_method: Literal["arithmetic mean", "geometric mean", "distance"],
|
|
696
|
+
weighting: Literal["cross-product-share", "own-share", None],
|
|
542
697
|
) -> float:
|
|
543
698
|
match weighting:
|
|
544
699
|
case "cross-product-share":
|
|
@@ -547,14 +702,14 @@ def _shrratio_boundary_intcpt(
|
|
|
547
702
|
_s_intcpt = mpf("1.0")
|
|
548
703
|
case None if agg_method == "distance":
|
|
549
704
|
_s_intcpt = _delta_star * mp.sqrt("2")
|
|
550
|
-
case None if agg_method == "arithmetic" and recapture_form == "inside-out":
|
|
705
|
+
case None if agg_method == "arithmetic mean" and recapture_form == "inside-out":
|
|
551
706
|
_s_intcpt = mp.fdiv(
|
|
552
707
|
mp.fsub(
|
|
553
708
|
2 * _delta_star * _r_val + 1, mp.fabs(2 * _delta_star * _r_val - 1)
|
|
554
709
|
),
|
|
555
710
|
2 * mpf(f"{_r_val}"),
|
|
556
711
|
)
|
|
557
|
-
case None if agg_method == "arithmetic":
|
|
712
|
+
case None if agg_method == "arithmetic mean" and recapture_form == "proportional":
|
|
558
713
|
_s_intcpt = mp.fsub(_delta_star + 1 / 2, mp.fabs(_delta_star - 1 / 2))
|
|
559
714
|
case _:
|
|
560
715
|
_s_intcpt = _s_2_pre
|
|
@@ -678,9 +833,9 @@ def boundary_plot(*, mktshares_plot_flag: bool = True) -> tuple[Any, ...]:
|
|
|
678
833
|
import matplotlib.ticker as mpt
|
|
679
834
|
|
|
680
835
|
mpl.use("pgf")
|
|
681
|
-
import matplotlib.pyplot as
|
|
836
|
+
import matplotlib.pyplot as _plt # noqa: ICN001
|
|
682
837
|
|
|
683
|
-
|
|
838
|
+
_plt.rcParams.update({
|
|
684
839
|
"pgf.rcfonts": False,
|
|
685
840
|
"pgf.texsystem": "lualatex",
|
|
686
841
|
"pgf.preamble": "\n".join([
|
|
@@ -719,7 +874,7 @@ def boundary_plot(*, mktshares_plot_flag: bool = True) -> tuple[Any, ...]:
|
|
|
719
874
|
})
|
|
720
875
|
|
|
721
876
|
# Initialize a canvas with a single figure (set of axes)
|
|
722
|
-
_fig =
|
|
877
|
+
_fig = _plt.figure(figsize=(5, 5), dpi=600)
|
|
723
878
|
_ax_out = _fig.add_subplot()
|
|
724
879
|
|
|
725
880
|
def _set_axis_def(
|
|
@@ -747,14 +902,14 @@ def boundary_plot(*, mktshares_plot_flag: bool = True) -> tuple[Any, ...]:
|
|
|
747
902
|
|
|
748
903
|
# Tick marks skip, size, and rotation
|
|
749
904
|
# x-axis
|
|
750
|
-
|
|
905
|
+
_plt.setp(
|
|
751
906
|
_ax1.xaxis.get_majorticklabels(),
|
|
752
907
|
horizontalalignment="right",
|
|
753
908
|
fontsize=6,
|
|
754
909
|
rotation=45,
|
|
755
910
|
)
|
|
756
911
|
# y-axis
|
|
757
|
-
|
|
912
|
+
_plt.setp(
|
|
758
913
|
_ax1.yaxis.get_majorticklabels(), horizontalalignment="right", fontsize=6
|
|
759
914
|
)
|
|
760
915
|
|
|
@@ -817,10 +972,10 @@ def boundary_plot(*, mktshares_plot_flag: bool = True) -> tuple[Any, ...]:
|
|
|
817
972
|
|
|
818
973
|
# Hide every other tick-label
|
|
819
974
|
for _axl in _ax1.get_xticklabels(), _ax1.get_yticklabels():
|
|
820
|
-
|
|
975
|
+
_plt.setp(_axl[::2], visible=False)
|
|
821
976
|
|
|
822
977
|
return _ax1
|
|
823
978
|
|
|
824
979
|
_ax_out = _set_axis_def(_ax_out, mktshares_plot_flag=mktshares_plot_flag)
|
|
825
980
|
|
|
826
|
-
return
|
|
981
|
+
return _plt, _fig, _ax_out, _set_axis_def
|
|
@@ -9,20 +9,22 @@ poor performance
|
|
|
9
9
|
|
|
10
10
|
from collections.abc import Callable
|
|
11
11
|
from dataclasses import dataclass
|
|
12
|
-
from importlib.metadata import version
|
|
13
12
|
from typing import Literal
|
|
14
13
|
|
|
15
14
|
import numpy as np
|
|
16
15
|
from mpmath import mp, mpf # type: ignore
|
|
17
16
|
from numpy.typing import NDArray
|
|
18
17
|
from scipy.spatial.distance import minkowski as distance_function # type: ignore
|
|
19
|
-
from sympy import lambdify, simplify, solve, symbols
|
|
18
|
+
from sympy import lambdify, simplify, solve, symbols # type: ignore
|
|
20
19
|
|
|
21
|
-
from .. import
|
|
22
|
-
from . import
|
|
23
|
-
|
|
20
|
+
from .. import VERSION # noqa: TID252
|
|
21
|
+
from .guidelines_boundary_functions import (
|
|
22
|
+
GuidelinesBoundary,
|
|
23
|
+
_shrratio_boundary_intcpt,
|
|
24
|
+
lerp,
|
|
25
|
+
)
|
|
24
26
|
|
|
25
|
-
__version__ =
|
|
27
|
+
__version__ = VERSION
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
mp.prec = 80
|
|
@@ -104,7 +106,7 @@ def hhi_delta_boundary_qdtr(_dh_val: float = 0.01, /) -> GuidelinesBoundaryCalla
|
|
|
104
106
|
|
|
105
107
|
def shrratio_boundary_qdtr_wtd_avg(
|
|
106
108
|
_delta_star: float = 0.075,
|
|
107
|
-
_r_val: float = 0.
|
|
109
|
+
_r_val: float = 0.85,
|
|
108
110
|
/,
|
|
109
111
|
*,
|
|
110
112
|
weighting: Literal["own-share", "cross-product-share"] | None = "own-share",
|
|
@@ -223,10 +225,10 @@ def shrratio_boundary_qdtr_wtd_avg(
|
|
|
223
225
|
|
|
224
226
|
def shrratio_boundary_distance(
|
|
225
227
|
_delta_star: float = 0.075,
|
|
226
|
-
_r_val: float = 0.
|
|
228
|
+
_r_val: float = 0.85,
|
|
227
229
|
/,
|
|
228
230
|
*,
|
|
229
|
-
agg_method: Literal["arithmetic", "distance"] = "arithmetic",
|
|
231
|
+
agg_method: Literal["arithmetic mean", "distance"] = "arithmetic mean",
|
|
230
232
|
weighting: Literal["own-share", "cross-product-share"] | None = "own-share",
|
|
231
233
|
recapture_form: Literal["inside-out", "proportional"] = "inside-out",
|
|
232
234
|
prec: int = 5,
|
|
@@ -236,7 +238,7 @@ def shrratio_boundary_distance(
|
|
|
236
238
|
symmetric merging-firm margins.
|
|
237
239
|
|
|
238
240
|
Reimplements the arithmetic-averages and distance estimations from function,
|
|
239
|
-
`shrratio_boundary_wtd_avg`but uses the Minkowski-distance function,
|
|
241
|
+
`shrratio_boundary_wtd_avg` but uses the Minkowski-distance function,
|
|
240
242
|
`scipy.spatial.distance.minkowski` for all aggregators. This reimplementation
|
|
241
243
|
is useful for testing the output of `shrratio_boundary_wtd_avg`
|
|
242
244
|
but runs considerably slower.
|
|
@@ -248,7 +250,7 @@ def shrratio_boundary_distance(
|
|
|
248
250
|
_r_val
|
|
249
251
|
recapture ratio
|
|
250
252
|
agg_method
|
|
251
|
-
Whether "arithmetic
|
|
253
|
+
Whether "arithmetic mean" or "distance".
|
|
252
254
|
weighting
|
|
253
255
|
Whether "own-share" or "cross-product-share".
|
|
254
256
|
recapture_form
|
|
@@ -306,7 +308,7 @@ def shrratio_boundary_distance(
|
|
|
306
308
|
)
|
|
307
309
|
|
|
308
310
|
match agg_method:
|
|
309
|
-
case "arithmetic":
|
|
311
|
+
case "arithmetic mean":
|
|
310
312
|
_delta_test = distance_function(
|
|
311
313
|
(_de_1, _de_2), (0.0, 0.0), p=1, w=_weights_i
|
|
312
314
|
)
|
|
@@ -368,11 +370,12 @@ def shrratio_boundary_distance(
|
|
|
368
370
|
# Area under boundary
|
|
369
371
|
_gbdry_area_total = 2 * _gbd_prtlarea - mp.power(_s_mid, "2")
|
|
370
372
|
|
|
371
|
-
_gbdry_points = np.
|
|
373
|
+
_gbdry_points = np.vstack((_gbdry_points, (mpf("0.0"), _s_intcpt))).astype(
|
|
372
374
|
np.float64
|
|
373
375
|
)
|
|
374
376
|
# Points defining boundary to point-of-symmetry
|
|
375
377
|
return GuidelinesBoundary(
|
|
376
|
-
np.
|
|
378
|
+
np.vstack((np.flip(_gbdry_points, 0), np.flip(_gbdry_points[1:], 1))),
|
|
377
379
|
round(float(_gbdry_area_total), prec),
|
|
378
380
|
)
|
|
381
|
+
|
|
@@ -9,7 +9,6 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
from collections.abc import Sequence
|
|
11
11
|
from dataclasses import dataclass
|
|
12
|
-
from importlib.metadata import version
|
|
13
12
|
from typing import Literal, TypeVar
|
|
14
13
|
|
|
15
14
|
import numpy as np
|
|
@@ -17,10 +16,9 @@ from numpy.typing import NBitBase, NDArray
|
|
|
17
16
|
from scipy.optimize import OptimizeResult, root # type: ignore
|
|
18
17
|
from scipy.stats import beta, chi2, norm # type: ignore
|
|
19
18
|
|
|
20
|
-
from .. import
|
|
21
|
-
|
|
22
|
-
__version__ = version(_PKG_NAME)
|
|
19
|
+
from .. import VERSION # noqa: TID252
|
|
23
20
|
|
|
21
|
+
__version__ = VERSION
|
|
24
22
|
|
|
25
23
|
TI = TypeVar("TI", bound=NBitBase)
|
|
26
24
|
|
|
@@ -8,21 +8,16 @@ https://github.com/numpy/numpy/issues/16313.
|
|
|
8
8
|
|
|
9
9
|
import concurrent.futures
|
|
10
10
|
from collections.abc import Sequence
|
|
11
|
-
from importlib.metadata import version
|
|
12
11
|
from multiprocessing import cpu_count
|
|
13
|
-
from typing import Literal
|
|
12
|
+
from typing import Literal
|
|
14
13
|
|
|
15
14
|
import numpy as np
|
|
16
15
|
from numpy.random import PCG64DXSM, Generator, SeedSequence
|
|
17
|
-
from numpy.typing import
|
|
16
|
+
from numpy.typing import NDArray
|
|
18
17
|
|
|
19
|
-
from .. import
|
|
18
|
+
from .. import VERSION # noqa: TID252
|
|
20
19
|
|
|
21
|
-
__version__ =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
TF = TypeVar("TF", bound=NBitBase)
|
|
25
|
-
TI = TypeVar("TI", bound=NBitBase)
|
|
20
|
+
__version__ = VERSION
|
|
26
21
|
|
|
27
22
|
NTHREADS = 2 * cpu_count()
|
|
28
23
|
DIST_PARMS_DEFAULT = np.array([0.0, 1.0], np.float64)
|
|
@@ -145,7 +140,7 @@ class MultithreadedRNG:
|
|
|
145
140
|
dist_type: Literal[
|
|
146
141
|
"Beta", "Dirichlet", "Gaussian", "Normal", "Random", "Uniform"
|
|
147
142
|
] = "Uniform",
|
|
148
|
-
dist_parms: NDArray[np.
|
|
143
|
+
dist_parms: NDArray[np.float64] | None = DIST_PARMS_DEFAULT,
|
|
149
144
|
seed_sequence: SeedSequence | None = None,
|
|
150
145
|
nthreads: int = NTHREADS,
|
|
151
146
|
):
|
|
@@ -211,7 +206,7 @@ class MultithreadedRNG:
|
|
|
211
206
|
def _fill(
|
|
212
207
|
_rng: np.random.Generator,
|
|
213
208
|
_dist_type: str,
|
|
214
|
-
_dist_parms: NDArray[np.
|
|
209
|
+
_dist_parms: NDArray[np.float64],
|
|
215
210
|
_out: NDArray[np.float64],
|
|
216
211
|
_first: int,
|
|
217
212
|
_last: int,
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
((# We force some color defintions here. These could be set in package code. #))
|
|
2
|
-
((* set obs_header_color = "0a6c97" *))
|
|
3
|
-
((* set sim_header_color = "646464" *))
|
|
4
|
-
((* set data_fill_color = "dfeadf" *))
|
|
5
1
|
% Tables in tikz, but first we need to define some colors for nonwhite text backgrounds
|
|
6
|
-
\definecolor{OBSHDRFill}{HTML}{
|
|
7
|
-
\definecolor{SIMHDRFill}{HTML}{
|
|
8
|
-
\definecolor{DataFill}{HTML}{
|
|
2
|
+
\definecolor{OBSHDRFill}{HTML}{0a6c97}
|
|
3
|
+
\definecolor{SIMHDRFill}{HTML}{646464}
|
|
4
|
+
\definecolor{DataFill}{HTML}{dfeadf}
|
|
9
5
|
% The below are definition's from Paul Tol's website, https://personal.sron.nl/~pault/
|
|
10
6
|
\definecolor{VibrBlue}{HTML}{0077bb}
|
|
11
7
|
\definecolor{BrightGreen}{HTML}{228833}
|
|
@@ -24,61 +20,60 @@
|
|
|
24
20
|
\tikzset{
|
|
25
21
|
% If you only have numbers, text depth = 0ex; if text, text depth = 0.25ex, (may need tweaking for alignment across cells)
|
|
26
22
|
anytext/.style = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, %
|
|
23
|
+
align = center,
|
|
24
|
+
font = \sffamily\scriptsize,
|
|
25
|
+
inner sep = 0pt,
|
|
26
|
+
text depth = 0pt,
|
|
27
|
+
}, %
|
|
32
28
|
hdrtext/.style = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, %
|
|
29
|
+
anytext,
|
|
30
|
+
text = white,
|
|
31
|
+
fill = OBSHDRFill,
|
|
32
|
+
}, %
|
|
37
33
|
notetext/.style = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
anytext,
|
|
35
|
+
font = \sffamily\tiny,
|
|
36
|
+
align = left,
|
|
41
37
|
},
|
|
42
38
|
anytable/.style = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
matrix of nodes,
|
|
40
|
+
nodes in empty cells,
|
|
41
|
+
column sep = -1.0\pgflinewidth,
|
|
42
|
+
row sep = -1.0\pgflinewidth,
|
|
43
|
+
inner sep = -0.25\pgflinewidth,
|
|
44
|
+
outer sep = -0.25\pgflinewidth,
|
|
45
|
+
nodes = {anchor = center, minimum height = 12.5pt,}
|
|
50
46
|
},
|
|
51
47
|
datatable/.style = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
48
|
+
anytable,
|
|
49
|
+
nodes = {
|
|
50
|
+
font = \sffamily\scriptsize\addfontfeatures{Numbers={Monospaced,Lining}},
|
|
51
|
+
align = right,
|
|
52
|
+
inner xsep = 3pt,
|
|
53
|
+
inner ysep = 0pt,
|
|
54
|
+
text depth = 0pt,
|
|
55
|
+
draw = none,
|
|
56
|
+
fill = none,
|
|
57
|
+
},
|
|
58
|
+
every even row/.style = {
|
|
59
|
+
nodes = {fill = DataFill}
|
|
60
|
+
},
|
|
65
61
|
},
|
|
66
62
|
hrow/.style = {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
anytable,
|
|
64
|
+
nodes = {
|
|
65
|
+
hdrtext,
|
|
66
|
+
draw = none,
|
|
67
|
+
fill = OBSHDRFill,
|
|
68
|
+
text width = 40pt,
|
|
69
|
+
},
|
|
74
70
|
},
|
|
75
71
|
hcol/.style = {
|
|
76
|
-
|
|
77
|
-
|
|
72
|
+
hrow,
|
|
73
|
+
nodes = {text width = 60pt,},
|
|
78
74
|
},
|
|
79
|
-
|
|
75
|
+
}
|
|
80
76
|
% Define layers for later reference
|
|
81
77
|
% https://tex.stackexchange.com/questions/40840/put-a-node-behind-another-in-a-tikz-diagram
|
|
82
78
|
\pgfdeclarelayer{background}
|
|
83
79
|
\pgfsetlayers{background,main}
|
|
84
|
-
|