bivariate_quantiles module¶
Bivariate vector quantiles and ranks.
This module implements the bivariate case of the vector quantiles and vector ranks construction of Chernozhukov, Galichon, Hallin, and Henry (2017).
The main workflow is:
- Solve for the dual weights
vwith :func:_solve_for_v. - Evaluate quantiles with :func:
bivariate_quantiles_vor :func:bivariate_quantiles. - Read off barycentric ranks with :func:
bivariate_ranks.
References
Chernozhukov, Galichon, Hallin, and Henry. "Monge-Kantorovich Depth, Quantiles, Ranks and Signs." Annals of Statistics 45(1), 2017.
bivariate_quantiles(y, tau, n_nodes=32, verbose=False)
¶
Solve for the dual weights and evaluate bivariate quantiles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
ndarray
|
Observations with shape |
required |
tau
|
ndarray
|
Query points in |
required |
n_nodes
|
int
|
Number of Chebyshev nodes for the quadrature. |
32
|
verbose
|
bool
|
Print optimisation diagnostics when |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Bivariate quantiles evaluated at |
Source code in bs_python_utils/stats/bivariate_quantiles.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
bivariate_quantiles_v(y, tau, v)
¶
Evaluate vector quantiles for fixed dual weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
ndarray
|
Observations with shape |
required |
tau
|
ndarray
|
Evaluation points in |
required |
v
|
ndarray
|
Dual weights solving the optimal transport problem, with length
|
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of quantile locations with shape |
Raises:
| Type | Description |
|---|---|
SystemExit
|
If |
Source code in bs_python_utils/stats/bivariate_quantiles.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
bivariate_ranks(y, n_nodes=32, verbose=False)
¶
Compute barycentric ranks for each observation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
ndarray
|
Observations with shape |
required |
n_nodes
|
int
|
Number of Chebyshev nodes used in the quadrature. |
32
|
verbose
|
bool
|
Print diagnostics when |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of average ranks (shape |
Source code in bs_python_utils/stats/bivariate_quantiles.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | |
bivariate_ranks_simul(x, rng, n_draws=10000, h_mult=100.0)
¶
This computes bivariate ranks for a matrix `x using simulations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
Input matrix of shape |
required |
rng
|
Generator
|
Random number generator for reproducibility. |
required |
n_draws
|
int
|
Number of random draws for the simulation. |
10000
|
h_mult
|
float
|
we set the bandwidth h as std(v_init)/h_mult, default is 100.0 |
100.0
|
Source code in bs_python_utils/stats/bivariate_quantiles.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |