Google Answers Logo
View Question
 
Q: Statistics ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Statistics
Category: Miscellaneous
Asked by: brkyrhrt99_00-ga
List Price: $2.00
Posted: 21 Sep 2002 12:51 PDT
Expires: 21 Oct 2002 12:51 PDT
Question ID: 67617
Websercher GA this is actually for you.  I need the code(Maple) that
was used to generate the answers of 4 integers when summed give you
20,when order matters and when it does not.

Clarification of Question by brkyrhrt99_00-ga on 21 Sep 2002 12:54 PDT
When order matters 1+2+3+14 and 1+3+2+14 are different.  When order
does not matter 1+2+3+14 and 1+3+2+14 are same.  Anyone can help me
out with this maple porgram help is appreciated.



Thanks
Answer  
Subject: Re: Statistics
Answered By: websearcher-ga on 21 Sep 2002 16:11 PDT
Rated:5 out of 5 stars
 
Hi brkyrhrt99_00:

I cleaned the file up a bit and added some comments for you. The Maple
input and comments are as follows. (Input lines have a > in front of
them, comments do not.)

> with(combinat);
Find all the compositions of 20 of 4 or less non-negative integers.
> allcomps := [op(composition(20,1)), op(composition(20,2)),
op(composition(20,3)), op(composition(20,4))];
Convert all the compositions to lists of 4 integers by padding with
zeroes.
> allcomps2 := [];
> for i from 1 to nops(allcomps) do
>    if nops(allcomps[i]) < 4 then
>       allcomps2 :=
[op(allcomps2),[0$(4-nops(allcomps[i])),op(allcomps[i])]]:
>    else
>       allcomps2 := [op(allcomps2),allcomps[i]]:
>    fi;
> od:
> allcomps2;
Sort inside the individual compositions.
> allcomps3 := map(sort, allcomps2):
> allcomps3;
Remove duplicate entries.
> alluncomps := [];
> for i from 1 to nops(allcomps3) do
>    if member(allcomps3[i], alluncomps) then
>       next;
>    else
>       alluncomps := [op(alluncomps), allcomps3[i]]:
>    fi:
> od:
> alluncomps;
How many are there?
> nops(alluncomps);
Find the number of possible permutations for each composition.
> map(numbperm, alluncomps, 4);
Sum the values up.
> convert(%, `+`);

I removed the output because it was really long. 

Hope this helps!

websearcher-ga

Clarification of Answer by websearcher-ga on 21 Sep 2002 16:16 PDT
Because of the line breaking, some of the input lines start on lines
without the > character. However, it should still be clear which lines
are comments.

websearcher-ga

Request for Answer Clarification by brkyrhrt99_00-ga on 22 Sep 2002 09:09 PDT
is this for when order matters or when it does not.? and what would be
the code for the other case.  THANK YOU>

Clarification of Answer by websearcher-ga on 22 Sep 2002 10:09 PDT
Actually, it is for computing *both* when ordering does and when it
doesn't count. In my method, you must compute without ordering first
in order to then compute with ordering. One follows from the other.

I've added a few additional comments to help you understand better. 

> with(combinat);
Find all the compositions of 20 of 4 or less non-negative integers.
> allcomps := [op(composition(20,1)), op(composition(20,2)), 
> op(composition(20,3)), op(composition(20,4))];
Convert all the compositions to lists of 4 integers by padding with
zeroes.
> allcomps2 := [];
> for i from 1 to nops(allcomps) do
>    if nops(allcomps[i]) < 4 then
>       allcomps2 := [op(allcomps2),
>                    [0$(4-nops(allcomps[i])),
>                    op(allcomps[i])]]:
>    else
>       allcomps2 := [op(allcomps2),allcomps[i]]:
>    fi;
> od:
> allcomps2;

Sort inside the individual compositions so that we can later eliminate
duplicate entries.
> allcomps3 := map(sort, allcomps2):
> allcomps3;
Remove duplicate entries to find the number of compositions when
ordering does not count.
> alluncomps := [];
> for i from 1 to nops(allcomps3) do
>    if member(allcomps3[i], alluncomps) then
>       next;
>    else
>       alluncomps := [op(alluncomps), allcomps3[i]]:
>    fi:
> od:
> alluncomps;
How many are there?
> nops(alluncomps);

Find the number of possible permutations for each individual
composition in order to compute how many compositions there are when
ordering does count.
> map(numbperm, alluncomps, 4);
Sum the values up.
> convert(%, `+`);

I have also put a copy of the complete document (output included)
online if you want to view it.

http://www.lucidmatrix.com/uploads/20output.txt 

websearcher-ga
brkyrhrt99_00-ga rated this answer:5 out of 5 stars
Excellent.  Thank you very much

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy