## risk.capital()


Allocates the distortion risk measure of a portfolio's total to its


Usage


``` python
risk.capital(
    pd,
    distortion,
    method="euler",
)
```


components.

Methods:

- `"euler"`: co-measure (for TVaR, the CoTVaRs); consistent with marginal changes to the portfolio.
- `"covariance"`: `rho(S) Cov(X_j, S) / Var(S)`.
- `"proportional"`: stand-alone measures scaled to `rho(S)`.
- `"marginal"`: `rho(S) - rho(S - X_j)` (Merton-Perold); does not add up to `rho(S)`.
- `"shapley"`: Shapley value of `v(T) = rho(sum of T)`; at most 12 components.


## Parameters


`pd: PredictiveDistribution`  
Components that add up to the portfolio.

`distortion: Distortion`  

`method: str = ``"euler"`  


## Returns


`Allocation`  


## Raises


`ValueError`  
For an unknown method, a constant total (`"covariance"`), stand-alone measures summing to 0 (`"proportional"`) or more than 12 components (`"shapley"`).


## Examples

``` python
>>> from prospicio.distributions import PredictiveDistribution
>>> from prospicio.risk import Distortion, capital
>>> pd = PredictiveDistribution(["lob"], [("motor",), ("property",)],
...                             [[1.0, 2.0], [4.0, 1.0], [2.0, 5.0], [3.0, 6.0]])
>>> a = capital(pd, Distortion.tvar(0.5))
>>> a.total, a.standalone, a.allocated
```

(8.0, \[3.5, 5.5\], \[2.5, 5.5\])

``` python
>>> a.diversification_benefit()
```

1.0
