Hi! I am trying to find all the possible weights that sum to one:
weights = Table[0.05*i,{i,0,20}] (* list of weights *)
n= 2
alltuples =Tuples[weights,n]; (*generate all tuples *)
Length[alltuples] (* number of tuples there are *)
Select[alltuples, Plus@@#==1&] (*list of all the tuples that sum to one *)
So this works and I get all the permutations that add to 1. However I want this done with n = 9 and n=10. This is not possible as it crashes (due to memory issues). You can try setting n=9 and the code won't work.
Is there a more elegant way to approach this problem? I guess I am using a brute force method which is not appropriate given the size of the problem.
Thanks! Priyan.