[R] Integer Sample with Mean Dependent on Size
Richard O'Keefe
r@oknz @end|ng |rom gm@||@com
Thu Aug 1 13:17:30 CEST 2019
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.
[[alternative HTML version deleted]]
More information about the R-help
mailing list