[R] Integer Sample with Mean Dependent on Size

Lorenzo Isella |orenzo@|@e||@ @end|ng |rom gm@||@com
Thu Aug 1 13:28:02 CEST 2019


Hello,

On Thu, Aug 01, 2019 at 11:17:30PM +1200, Richard O'Keefe wrote:
>2(N-1)/N = 2 - 2/N.
>So one way to get exactly that mean is to make all the numbers
>2 except for two of them which are 1.
>
>N < 2 : can't be done.
>N = 2 : only [1,1] does the job.
>N = 3 : the sum of the three numbers must be 4, so none of them
>        can be 3, so [1,1,2] [1,2,1] [2,1,1] are the only
>        possibilities.
>N = 4 : [1,1,1,3] [1,1,2,2] [1,1,3,1] [1,2,1,2] [1,2,2,1] [1,3,1,1]
>[2,1,1,2] [2,1,2,1] [2,2,1,1] [3,1,1,1]
>
>Is there a pattern here?
>Yes.  There must be an integer k such that 0 <= 2k <= N-2
>and then you have a rearrangement of (k+2) 1s, (N-2-2k) 2s, and k 3s.


This is what I did by solving a set of equations

n1+n2+n3=N (i.e. the number of 1, 2 and 3 equals N, the length of my sample) and
n2+2*n2+3*n3=2*(N-1)

without delving into the details, you are composing (fractal) structures of N spheres in 3D, with an algorithm which establishes that every sphere has on average (2*N-1)/N neighbours. One solution is a simple chain, without bifurcations, where every sphere has two neighbours apart from the two terminal spheres, each of which has just one neighbour. Whenever a bifurcation arises, one sphere will have three neighbors.

L.



More information about the R-help mailing list