## 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

Stores the **N** largest positive elements from **Data**
in the **Weights** array, normalized so that they sum up
to **1**; smaller and negative elements are ignored.
A weight limit can be applied individually per **
Data** element of or globally for all elements;
it clips the weights at the limit and distributes the remainders among the other
positive weights.
The total weight sum can end
up less than **1** if the restriction to positive elements and
weight limits were otherwise violated.This function
is normally used to distribute asset weights in a
portfolio dependent on individual properties such as momentum.
### Parameters:

**Weights** |
Output array of size **Length **to receive
**N** normalized **Data**
elements. The other elements are 0. |

**Data** |
Input array of size **Length**, for instance the momentums of
portfolio components. |

**Length** |
Size of the **Weights**, **Data**, and
**Caps** arrays. |

**N** |
Max number of resulting nonzero 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, OptimalF
► latest
version online