Code covered by the BSD License  

Highlights from
All Sums

5.0 | 1 rating Rate this file 6 Downloads (last 30 days) File Size: 2.27 KB File ID: #33454
image thumbnail

All Sums


Mike Sheppard (view profile)


26 Oct 2011 (Updated )

Distribution of unique sums among all combinations of vectors.

| Watch this File

File Information

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
Probability distribution of rolling a regular 6-sided die 100 times
plot(S,C./sum(C)), grid on
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.


This file inspired Sum Of Probability Distributions and Apply A Function To A Set Of Probability Distributions.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
08 Dec 2011 Mike Sheppard

Mike Sheppard (view profile)

For unequal probabilities see "Sum of probability distributions" #34082

Comment only
31 Oct 2011 Jonathan Sullivan  
27 Oct 2011

Generalized for multiple inputs, and across different vectors.

28 Oct 2011

Generalized to multiple inputs, fixed error checking and modified code for performance.

02 Nov 2011

Rephrased examples and summary

04 Apr 2012

Updated help section

Contact us