Stars and Bars Equivalence

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.



for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement


How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?



This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.




Stars and Bars:




If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.



If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$











share|cite|improve this question





















  • Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
    – Vee Hua Zhi
    Sep 10 at 1:08










  • It gave me $10+3-1choose3$, without "(" and ")"
    – hioqobipb
    Sep 10 at 2:04















up vote
1
down vote

favorite












My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.



for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement


How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?



This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.




Stars and Bars:




If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.



If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$











share|cite|improve this question





















  • Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
    – Vee Hua Zhi
    Sep 10 at 1:08










  • It gave me $10+3-1choose3$, without "(" and ")"
    – hioqobipb
    Sep 10 at 2:04













up vote
1
down vote

favorite









up vote
1
down vote

favorite











My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.



for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement


How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?



This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.




Stars and Bars:




If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.



If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$











share|cite|improve this question













My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.



for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement


How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?



This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.




Stars and Bars:




If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.



If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$








combinatorics






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Sep 9 at 5:49









hioqobipb

153




153











  • Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
    – Vee Hua Zhi
    Sep 10 at 1:08










  • It gave me $10+3-1choose3$, without "(" and ")"
    – hioqobipb
    Sep 10 at 2:04

















  • Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
    – Vee Hua Zhi
    Sep 10 at 1:08










  • It gave me $10+3-1choose3$, without "(" and ")"
    – hioqobipb
    Sep 10 at 2:04
















Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
– Vee Hua Zhi
Sep 10 at 1:08




Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
– Vee Hua Zhi
Sep 10 at 1:08












It gave me $10+3-1choose3$, without "(" and ")"
– hioqobipb
Sep 10 at 2:04





It gave me $10+3-1choose3$, without "(" and ")"
– hioqobipb
Sep 10 at 2:04











1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.



where $a,b,c,d$ each represents the 'stars' in every container:




For example in $(∗∗∗|∗|∗∗|∗∗∗)$ $a=3, b=1, c=2, d=3$




Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.



Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.




*Your formula for stars and bars is not correct.




Source: Brilliant.org



The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is



$$ binomn+r-1n = binomn+r-1r-1. _square $$




which is not the same as the formula you have given, i.e. $n + (r-1)chooser$







share|cite|improve this answer






















  • But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
    – hioqobipb
    Sep 9 at 17:13










  • I have edited my solution
    – Vee Hua Zhi
    Sep 10 at 1:07










  • The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
    – hioqobipb
    Sep 10 at 2:06











  • The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
    – Vee Hua Zhi
    Sep 11 at 3:44










  • You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
    – Vee Hua Zhi
    Sep 11 at 3:45










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2910444%2fstars-and-bars-equivalence%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.



where $a,b,c,d$ each represents the 'stars' in every container:




For example in $(∗∗∗|∗|∗∗|∗∗∗)$ $a=3, b=1, c=2, d=3$




Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.



Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.




*Your formula for stars and bars is not correct.




Source: Brilliant.org



The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is



$$ binomn+r-1n = binomn+r-1r-1. _square $$




which is not the same as the formula you have given, i.e. $n + (r-1)chooser$







share|cite|improve this answer






















  • But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
    – hioqobipb
    Sep 9 at 17:13










  • I have edited my solution
    – Vee Hua Zhi
    Sep 10 at 1:07










  • The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
    – hioqobipb
    Sep 10 at 2:06











  • The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
    – Vee Hua Zhi
    Sep 11 at 3:44










  • You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
    – Vee Hua Zhi
    Sep 11 at 3:45














up vote
2
down vote



accepted










Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.



where $a,b,c,d$ each represents the 'stars' in every container:




For example in $(∗∗∗|∗|∗∗|∗∗∗)$ $a=3, b=1, c=2, d=3$




Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.



Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.




*Your formula for stars and bars is not correct.




Source: Brilliant.org



The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is



$$ binomn+r-1n = binomn+r-1r-1. _square $$




which is not the same as the formula you have given, i.e. $n + (r-1)chooser$







share|cite|improve this answer






















  • But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
    – hioqobipb
    Sep 9 at 17:13










  • I have edited my solution
    – Vee Hua Zhi
    Sep 10 at 1:07










  • The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
    – hioqobipb
    Sep 10 at 2:06











  • The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
    – Vee Hua Zhi
    Sep 11 at 3:44










  • You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
    – Vee Hua Zhi
    Sep 11 at 3:45












up vote
2
down vote



accepted







up vote
2
down vote



accepted






Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.



where $a,b,c,d$ each represents the 'stars' in every container:




For example in $(∗∗∗|∗|∗∗|∗∗∗)$ $a=3, b=1, c=2, d=3$




Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.



Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.




*Your formula for stars and bars is not correct.




Source: Brilliant.org



The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is



$$ binomn+r-1n = binomn+r-1r-1. _square $$




which is not the same as the formula you have given, i.e. $n + (r-1)chooser$







share|cite|improve this answer














Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.



where $a,b,c,d$ each represents the 'stars' in every container:




For example in $(∗∗∗|∗|∗∗|∗∗∗)$ $a=3, b=1, c=2, d=3$




Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.



Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.




*Your formula for stars and bars is not correct.




Source: Brilliant.org



The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is



$$ binomn+r-1n = binomn+r-1r-1. _square $$




which is not the same as the formula you have given, i.e. $n + (r-1)chooser$








share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Sep 11 at 3:40

























answered Sep 9 at 6:30









Vee Hua Zhi

74718




74718











  • But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
    – hioqobipb
    Sep 9 at 17:13










  • I have edited my solution
    – Vee Hua Zhi
    Sep 10 at 1:07










  • The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
    – hioqobipb
    Sep 10 at 2:06











  • The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
    – Vee Hua Zhi
    Sep 11 at 3:44










  • You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
    – Vee Hua Zhi
    Sep 11 at 3:45
















  • But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
    – hioqobipb
    Sep 9 at 17:13










  • I have edited my solution
    – Vee Hua Zhi
    Sep 10 at 1:07










  • The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
    – hioqobipb
    Sep 10 at 2:06











  • The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
    – Vee Hua Zhi
    Sep 11 at 3:44










  • You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
    – Vee Hua Zhi
    Sep 11 at 3:45















But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
– hioqobipb
Sep 9 at 17:13




But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
– hioqobipb
Sep 9 at 17:13












I have edited my solution
– Vee Hua Zhi
Sep 10 at 1:07




I have edited my solution
– Vee Hua Zhi
Sep 10 at 1:07












The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
– hioqobipb
Sep 10 at 2:06





The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
– hioqobipb
Sep 10 at 2:06













The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
– Vee Hua Zhi
Sep 11 at 3:44




The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
– Vee Hua Zhi
Sep 11 at 3:44












You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
– Vee Hua Zhi
Sep 11 at 3:45




You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
– Vee Hua Zhi
Sep 11 at 3:45

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2910444%2fstars-and-bars-equivalence%23new-answer', 'question_page');

);

Post as a guest













































































這個網誌中的熱門文章

tkz-euclide: tkzDrawCircle[R] not working

How to combine Bézier curves to a surface?

1st Magritte Awards