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.

Parameters:

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

Returns

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.

Parameters:

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.

Returns

Sum of weights after applying the limits.

Example:

var* Filter = { 1,2,3,2,1,0 };
filter(Data,Length,renorm(Filter,5,1));

See also:

filter, markowitz

► latest version online