How can I use the ( nchoosek ) for this case nchoosek(x,y) where x=[1:1:80] , and y=64;
3 ビュー (過去 30 日間)
I have the following
C = nchoosek(x,y)
and I need to find the same process for
C = nchoosek(x,y)
I get the following warrning message
Warning: Result may not be exact. Coefficient is greater than 9.007199e+15 and is only
accurate to 15 digits.
How can i find C ???
回答 (3 件)
Jan 2022 年 7 月 20 日
編集済み: Jan 2022 年 7 月 20 日
80 over 64 is 26'958'221'130'508'525. Then nchoosek(1:80, 64) needs 26958221130508525 * 64 * 8 Bytes in the RAM, which is 1,38 PetaByte, which 1'380'000 GigaByte.
There is no computer on earth, which has this amout of RAM.
You can determine the value of 80 over 64 accurately by:
Creating nchoosek(1:26, 16) takes 0.5 seconds in my Matlab 2018b and replies a matrix using 1.1GB. If this could be extrapolated, producing nchoosek(1:80, 64) would take about 8 day to be computed.
Jon 2022 年 7 月 20 日
b = nchoosek(80,64)
You will see that there are approximately 2.6958 E16 ways of choosing 64 elements out of your vector of 80 values.
The result of
C = nchoosek(1:80,64)
would most likely exceed the size of your available memory
I suggest that you further evaluate what you are actually trying to achieve. What would you do with all of those choices?
John D'Errico 2022 年 7 月 20 日
As Jan pointed out, you CANNOT solve your problem in this way. Using nchoosek in this form, it almost always is a form of brute force. Evaluate EVERY possible solution, then pick the one that is best.
And the problem is, you can't do it. The search space is simply too large. We get spoiled, with big fast computers on our laps or desks, thinking they can do anything, solve every possible problem. They can't. And you cannot afford a big enough comouter, because as soon as you do, your problem will expand to nchoosek(1:100) or 200, etc.
A basic rule of computing that I posed many years ago is that problems ALWAYS expand to be as large as the computer you have at your fingertips, and then just a bit larger. After all, why solve small problems? Someone else already did them, and those problems were easy.
The thing is, this means you need to use creativity. Think outside the box. Mathematics is the means of avoiding those brute force problems. Convert your large problem into something that can be solved using existing tools and methods.
One idea may be to convert your problem into a search, perhaps some sort of search routine that uses a genetic algorithm to find the solution, but something that will not need to evaluate every possible solution in the search space.
Or you may be abe to use other techniques, other ways to view the problem. Can you simplify it in some way, find an approximation that will reduce the computational load.
Of course, these are just general thoughts, that reflect on the fact you CANNOT solve the problem using brute force, so it leaves you little choice if you want to find a solution.