Robin Hankin wrote:
> Hello Amin
>
> The partitions library does this.
>
> If N=4 and k=3:
>
> > library(partitions)
> > blockparts(rep(4,3),4)
>
> [1,] 4 3 2 1 0 3 2 1 0 2 1 0 1 0 0
> [2,] 0 1 2 3 4 0 1 2 3 0 1 2 0 1 0
> [3,] 0 0 0 0 0 1 1 1 1 2 2 2 3 3 4
> >
>
> The solutions are enumerated in
Hello Amin
The partitions library does this.
If N=4 and k=3:
> library(partitions)
> blockparts(rep(4,3),4)
[1,] 4 3 2 1 0 3 2 1 0 2 1 0 1 0 0
[2,] 0 1 2 3 4 0 1 2 3 0 1 2 0 1 0
[3,] 0 0 0 0 0 1 1 1 1 2 2 2 3 3 4
>
The solutions are enumerated in the columns.
HTH
rksh
On 19 Nov 2007
Dear all,
Is there any method in R to find all possible nonnegative integer
solutions to the linear equation with unit coefficients as follow:
X1+X2+...+Xk=N
Thank you,
Amin Zollanvari
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/l
3 matches
Mail list logo