View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harlan Grove Harlan Grove is offline
external usenet poster
 
Posts: 733
Default taking average of each set of all possible combinations

"Tom Mort" wrote...
I'd like to take the average of all possible combinations of an array
and get the average of each set of permutations. I will specify how
many permutions per set. Ultimately I will then look at the the
percentage of these averages above or below a certain number.


You're being sloppy with terminology. {1,2,3} and {3,1,2} represent
different permutations of the same combination, and all permutations of the
same combination have the same average (and sum and count and variance . .
..), so kinda pointless to average different permutations.

A set with N elements has 2^N total subsets, and 2^N-2 nontrivial proper
subsets, so a set with, say, 32 elements has over 4 billion (US - 10^9)
subsets, or combinations of 1 to 32 elements.

If you have an array of 32 positive numbers, and you want to know the
percentage of all of its subsets with averages less than X, there are better
approaches to take than brute force. Obviously all subsets containing only
elements each less than X will have averages less than X, and all subsets
containing only elements greater than X will have averages greater than X.
More generally, all subsets of n < 32 elements which sum to less than n*X
will have averages less than X, and all that sum to more than n*X will have
averages greater than X.

These sorts of optimizations could be done manually, and they'll be a lot
faster than code implementing brute force algorithms.