1

I have a portfolio of 3 securities and I want to generate all possible permutations of securities weights. Single weight spans between 0 and 1.0 with increase of 0.1: (0, 0.1, 0.2, ..., 0.9, 1.0). Sum of all weights has to be equal 1 and all weights have to be nonnegative, for example if first weight is equal to 0.9 then either the second [0.9, 0.1, 0.0] or the third weight has to be 0.1 [0.9, 0.0, 0.1].

How can I define a mathematical formula to calculate number of all permutations with repetitions? Right now to calculate all valid permutations I first generate all permutations and then discard those with sum different than 1 but this approach won't work for portfolios with high number of securities.

  • Do you just need the count are you need the complete layout of the permuations? – Satish Ramanathan Sep 18 '18 at 15:35
  • It looks like you meant that all weights have to be nonnegative. If they have to be positive, then the largest weight you could use would be $0.8$ since $0.8 + 0.1 + 0.1 = 1$. – N. F. Taussig Sep 18 '18 at 16:22
  • Updated question, I only need to calculate number of all permutations with repetitions. @N.F.Taussig No, the largest weight that can be used is 1.0 then rest of the weights are 0.0 . – Michael Dz Sep 18 '18 at 17:00
  • The wording could be improved. You should not say all weights have to be positive when you are allowing a weight of $0$. You should say nonnegative. Also, if I understand the question correctly, what matters is the weight of each type of security. – N. F. Taussig Sep 18 '18 at 17:03

4 Answers4

2

Let's begin with your example of three types of securities with weights that are multiples of $0.1$. If we take $0.1$ as our unit, then we must distribute ten units among the three types of securities. Let $x_i$ be the number of units of the $i$th security. Then $$x_1 + x_2 + x_3 = 10 \tag{1}$$ is an equation in the nonnegative integers.

A particular solution of the equation corresponds to the placement of two addition signs in a row of ten ones. For instance, $$1 1 1 1 1 + 1 1 1 + 1 1$$ corresponds to the solution $x_1 = 5$, $x_2 = 3$, $x_3 = 2$ and the weights $0.5$ for the first security, $0.3$ for the second security, and $0.2$ for the third security, while $$1 1 1 1 1 1 1 1 + 1 1 +$$ corresponds to the solution $x_1 = 8$, $x_2 = 2$, $x_3 = 0$ and the weights $0.8$ for the first security, $0.2$ for the second security, and $0$ for the third security.

The number of solutions of equation 1 is the number of ways two addition signs can be placed in a row of ten ones, which is $$\binom{10 + 2}{2} = \binom{12}{2}$$ since we must select which two of the twelve positions required for ten ones and two addition signs will be filled with addition signs.

Generalization

Let's say that you instead are selecting $n$ types of securities, with weights that are multiples of $1/k$. In that case, we take $1/k$ as our unit, so we have a total of $k$ units. For instance, if $k = 10$, then each unit is $0.1$ as in your example. If $k = 100$, then each unit is $0.01$. If we let $x_i$, $1 \leq i \leq n$, be the number of units of the $i$th security, then $$x_1 + x_2 + x_3 + \cdots + x_n = k \tag{2}$$ is an equation in the nonnegative integers. A particular solution corresponds to the placement of $n - 1$ addition signs in a row of $k$ ones. The number of solutions of equation 2 in the nonnegative integers is $$\binom{k + n - 1}{n - 1}$$ since we must choose which $n - 1$ of the $n + k - 1$ positions required for $k$ ones and $n - 1$ addition signs will be filled with addition signs.

N. F. Taussig
  • 76,571
1

This is a stars and bars problem. You are looking for solutions to $x+y+z=10$ with each variable an integer in $[0,10]$. Add $1$ to each so you are solving $x'+y'+z'=13$ with each variable in $[1,11]$. Now imagine a row of $13$ stars with places for bars between them. You will place two bars to divide $x'$ from $y'$ from $z'$, so you are selecting two places out of $12$. There are ${12 \choose 2}=66$ ways to do this

Ross Millikan
  • 374,822
0

Number of ways to write n as a sum of k nonnegative integers.

In the above answer, he is writing n as a sum of k non negative integers. Thus relating your problem to this, I would assume that you will have to write 10 (=n) as a sum of j (=k) ( where j is the number of securities) non negative integers (0-10). It has also provided you a site to list all permutations. Good luck.

Once you get the list remove all permuations where you have 10 and divide rest of all permutations by 10 to give you the desired result.

0

We can consider the equation x + y + z = 10 where x, y and z can take integer values ranging from 0 to 10. We can parallel this problem with the following : in how many ways can we permute 12 objects if 10 objects are the same and the 2 others are also the same. Consider 10 circles and 2 seperators. On the left of seperator 1 we have x circles, in between the 2 seperators we have y circles, and on the right of seperator 2 we have z circles. We therefore have 12!/(10!*2!) Ways of solving this equation. This reasoning can be extended very easily to more complicated versions of the same problem.

Jonah
  • 571
  • The sentence about permuting $10$ objects that are the same and $2$ objects that are the same is confusing. It would be clearer if you just said in how many ways can we permute $10$ identical circles and $2$ identical separators. – N. F. Taussig Sep 19 '18 at 10:34