apaRandomWeights.Restricted(NumberOfAllocations, PortfolioExposure, LowerBounds, UpperBounds)
=apaRandomWeights.Restricted(NumberOfAllocations, PortfolioExposure, LowerBounds, UpperBounds)Result
Generates random allocations subject to lower and upper bounds and a constraint on total exposure. The algorithm used is Latin hypercube sampling.
Syntax
NumberOfAllocations: number of random allocations to generate
PortfolioExposure: value of the equality constraint on total portfolio exposure, i.e. the sum of constituent exposures
LowerBounds: 1 x c vector of constituent lower bounds
UpperBounds: 1 x c vector of constituent upper bounds
Algorithm
Each allocation is generated in two steps. First, every constituent weight is drawn by Latin hypercube sampling within its bounds: the range from the lower to the upper bound is divided into NumberOfAllocations intervals of equal width, and each interval is used exactly once per constituent across the allocations.
Second, the equality constraint is imposed. With the residual e = PortfolioExposure - sum of the weights, all weights are moved towards their upper bounds if e > 0, or towards their lower bounds if e < 0, each in proportion to its remaining room: w(j) + s (UpperBound(j) - w(j)) or w(j) - s (w(j) - LowerBound(j)), where s is the absolute residual divided by the total remaining room. Every allocation then sums exactly to PortfolioExposure and respects all bounds.
Remarks
The constraints are feasible if the sum of the lower bounds does not exceed PortfolioExposure and PortfolioExposure does not exceed the sum of the upper bounds; otherwise the function returns an error message. The adjustment in the second step changes the distribution of the weights, so the individual columns are no longer exactly Latin hypercube stratified, and the allocations are not uniformly distributed over the feasible set. With symmetric bounds the expected weights are equal across constituents.
