Thread Subject: I want to know the number of permutations.

Subject: I want to know the number of permutations.

From: Husam Aldahiyat

Date: 29 Jun, 2009 15:16:02

Message: 1 of 7

Hello,
Just like we do with nchoosek, I want a way to obtain the number of rows of the output of perms, without obtaining what they are.

Please help!

Specifically, I want the following:

                          length(unique(perms([ones(1,20),zeros(1,20)])))

or

                          length(perms([ones(1,20),zeros(1,20)]))/400

(I think they give the same result)

end

Subject: I want to know the number of permutations.

From: Bruno Luong

Date: 29 Jun, 2009 15:36:01

Message: 2 of 7

"Husam Aldahiyat" <numandina@gmail.com> wrote in message <h2alri$2o3$1@fred.mathworks.com>...
> Hello,
> Just like we do with nchoosek, I want a way to obtain the number of rows of the output of perms, without obtaining what they are.
>
> Please help!
>
> Specifically, I want the following:
>
> length(unique(perms([ones(1,20),zeros(1,20)])))

% I guess you miss 'rows'
m = 2;
n = 6;
p=unique(perms([ones(1,m),zeros(1,n)]),'rows');

size(p,1) == nchoosek(m+n,n)

% Bruno

Subject: I want to know the number of permutations.

From: Alan B

Date: 29 Jun, 2009 15:44:02

Message: 3 of 7

"Husam Aldahiyat" <numandina@gmail.com> wrote in message <h2alri$2o3$1@fred.mathworks.com>...
> Hello,
> Just like we do with nchoosek, I want a way to obtain the number of rows of the output of perms, without obtaining what they are.
>
> Please help!
>
> Specifically, I want the following:
>
> length(unique(perms([ones(1,20),zeros(1,20)])))
>
> or
>
> length(perms([ones(1,20),zeros(1,20)]))/400
>
> (I think they give the same result)
>
> end

If you're just interested in examples similar to the one you give, look at this: http://www.research.att.com/~njas/sequences/index.html?q=2+6+20+70+252&language=english&go=Search .

Subject: I want to know the number of permutations.

From: Husam Aldahiyat

Date: 29 Jun, 2009 15:45:03

Message: 4 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <h2an11$k7n$1@fred.mathworks.com>...
> "Husam Aldahiyat" <numandina@gmail.com> wrote in message <h2alri$2o3$1@fred.mathworks.com>...
> > Hello,
> > Just like we do with nchoosek, I want a way to obtain the number of rows of the output of perms, without obtaining what they are.
> >
> > Please help!
> >
> > Specifically, I want the following:
> >
> > length(unique(perms([ones(1,20),zeros(1,20)])))
>
> % I guess you miss 'rows'
> m = 2;
> n = 6;
> p=unique(perms([ones(1,m),zeros(1,n)]),'rows');
>
> size(p,1) == nchoosek(m+n,n)
>
> % Bruno

Actually I used rows in my code I just forgot to put it in the message.

About your code, I don't understand the final line. I have a headache please bear with me! And I want m and n to be 20 and 20. That's why I'm looking for a getaround, because the matrix for perms would be very big to do it normally :(

Subject: I want to know the number of permutations.

From: Husam Aldahiyat

Date: 29 Jun, 2009 15:52:01

Message: 5 of 7

Wow it was nchoosek(40,20) all along!!! Why didn't I see that!

Thanks for the help, and the link is very helpful, thanks a lot Alan B.

Subject: I want to know the number of permutations.

From: Husam Aldahiyat

Date: 29 Jun, 2009 16:02:01

Message: 6 of 7

"Husam Aldahiyat" <numandina@gmail.com> wrote in message <h2anv1$m0g$1@fred.mathworks.com>...
> Wow it was nchoosek(40,20) all along!!! Why didn't I see that!
>
> Thanks for the help, and the link is very helpful, thanks a lot Alan B.

I think Alan B's link givers the fastest method for this case.

factorial(40)/(factorial(20))^2

By the way this is the answer to the following question:

In a 20 by 20 square grid, how many ways can one travel from one corner to the opposite without backtracking.

Subject: I want to know the number of permutations.

From: Bruno Luong

Date: 29 Jun, 2009 16:11:02

Message: 7 of 7

"Husam Aldahiyat" <numandina@gmail.com> wrote in message <h2aohp$1mm$1@fred.mathworks.com>...

>
> In a 20 by 20 square grid, how many ways can one travel from one corner to the opposite without backtracking.

The general case is showed here, if you haven't pay attention
http://www.mathworks.com/matlabcentral/newsreader/view_thread/253745#658145

Bruno

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
perms Husam Aldahiyat 29 Jun, 2009 11:19:03
recursion Husam Aldahiyat 29 Jun, 2009 11:19:03
memory Husam Aldahiyat 29 Jun, 2009 11:19:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com