I have 3 variables where each of the variable's value can range from .05 to 1. The constraints are that the sum of variables should be 1 and the variables should always be a multiple of .05
I want to generate all possible combination of these 3 variables and use these weights for some calculation in each iteration. So for example
Iteration 1:
W1 : .05 W2 : .05 W3: .9
Iteration 2:
W1 : .1 W2 : .05 W3: .85
So on and so forth, so my question is is there a package in python/ or any other way which can do this, where I can specify the increment size(.05), the constraints(summation of variables = 1) in this case and generate such combinations
Lets try someting new with meshgrid
to generate all possible combinations where sum is 1
v = np.arange(0.05, 1.05, 0.05)
G = np.meshgrid(v, v, v)
m = sum(G) == 1
for (w1, w2, w3) in zip(*[g[m] for g in G]):
print(w1, w2, w3)
...
0.4 0.05 0.55
0.45 0.05 0.5
0.5 0.05 0.45
0.55 0.05 0.4
...