function nchoosek (v,k) very large vector gives Inf

7 views (last 30 days)
I have a column vector 510 X 1 ( listOfRmsValues) and I want to find all possible combinations taken 30 elements( sampleSize ) at a time . Using nchoose(v,k) gives Inf as v should not be more than 15 as suggested by Matlab as it exceeds the maximum limit Matlab can handle.I even tried using vpi as suggested in other matlab forums but I get an error
Error using vpi/nchoosek (line 46)
n must be scalar, integer >= 1
This is my code snippet
function [ meanVal , stdDev , binomialCoefficient ] = MeanDistribution ( listOfRmsValues ,quantity ,sampleSize )
tic
binomialCoefficient = nchoosek( vpi(quantity) ,sampleSize);
allPossibleCombinations = nchoosek (vpi(listOfRmsValues) , sampleSize); % I get the error oIn this line.
sampleMean = zeros ( binomialCoefficient , 1 );
sampleStdDeviation = zeros ( binomialCoefficient , 1 );
Is vpi not built to handle vectors? If not how can I solve this problem.
I know the number is very huge.Further more,I want to take mean of all combinations too .Can anyone suggest me a solution.
Thank you

Accepted Answer

Walter Roberson
Walter Roberson on 26 Apr 2016
If your computer was able to produce 10^9 entries per second (about 3 clock cycles on your processor), then then 2664780071347123896227890686628472969646736772415 results would take over 8.4 * 10^31 years and would require about 1.6 * 10^38 terabytes to store.
When did you say the deadline was for this task?
  2 Comments
Saurabh Bagalkar
Saurabh Bagalkar on 26 Apr 2016
Hello Sir, So what do you suggest I do in this case?
Walter Roberson
Walter Roberson on 26 Apr 2016
What I suggest you do in this case is re-think why you need all of those combinations.
If the answer is that you want to do an exhaustive search to find the absolute best combination for some optimization, then you will find that an exhaustive search is simply not possible in a reasonable amount of time.
For some functions to be optimized, it is possible to break down the task into smaller pieces that can be reasoned about and individually computed in a feasible amount of time, and to show that the subproblems together must give the optimal solution. However, this depends on the structure of the hypothetical function to be optimized.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!