ALLSUMS Distribution of unique sums among all combinations of vectors.
[S,C]=ALLSUMS(IN) depending on input IN, will do one of two different procedures for calculating all unique combinations of sums.
The output vectors, S and C, are respectively the list of unique sums, and the count distribution for those sums among all combinations.
[S,C]=ALLSUMS(VEC) for a single input vector of length N, returns the distribution of unique sums among the (2^N)-1 combinations of non-empty subsets of elements within VEC.
Number of ways to have a total of 250 using only the odd numbers from 1 to 100.
[S,C]=ALLSUMS(VEC,K) with vector VEC of length N, assumes theequivalent scenario of rolling a N-sided die, with values VEC, K times and returns the distributions of unique sums among all N^K combinations of values.
[S,C]=ALLSUMS(VEC1,K1,VEC2,K2,...) with vectors of length N1, N2, ... assumes the equivalent scenario of rolling a N1-sided die, with values VEC1, K1 times; then rolling a N2-sided dice, with values VEC2, K2 times; etc. and returns the distribution of unique sums among all (N1^K1)*(N2^K2)*... combinations of values
SINGLE VECTOR, REPEATED
Probability distribution of rolling a regular 6-sided die 100 times
plot(S,C./sum(C)), grid on
MULTIPLE VECTORS, REPEATED
Probability of the total yielding exactly zero when rolling a
A) six-sided die with values [-5:0] ten times, and then a
B) ten-sided die with values [-4:5] twenty times.