renorm (var* Data, int Length, var Sum) : var*

Modifies the Data array by multiplying all elements with a factor so that they sum up to Sum. This function can be used to normalize a list of weights to a certain total.


Data Array or series to be normalized.
Length Number of elements to be normalized.
Sum Resulting sum of elements.


Modified Data

distribute (var* Weights, var* Data, int Length, int N, var* Caps) : var

distribute (var* Weights, var* Data, int Length, int N, var Cap) : var

Normalizes the Data array so that the N largest positive elements sum up to 1; smaller and negative elements are ignored. The resulting array is stored in Weights. A weight limit can be applied individually or globally; it clips the weights at the limit and distributes the remainders among the other positive weights. Depending on N and the weight cap, the total weight sum can end up less than 1.This function is normally used to distribute asset weights in a portfolio dependent on individual properties such as momentum.


Weights Output array to receive the normalized Data elements.
Data Input array to be normalized.
Length Size of the Weights, Data, and Caps arrays.
N Max number of resulting weights, or 0 for distributing all weights.
Caps Array of weight limits in the 0..1 range, or 0 for no weight limit.
Cap Global limit in the 0..1 range to be applied to all weights, or 0 for no weight limits.


Sum of weights after applying the limits.


var* Filter = { 1,2,3,2,1,0 };

See also:

filter, markowitz

► latest version online