[R] Integer Sample with Mean Dependent on Size
Gerrit Eichner
gerr|t@e|chner @end|ng |rom m@th@un|-g|e@@en@de
Thu Aug 1 12:37:47 CEST 2019
n_1 + ... + n_N = 2(N-1) is requested for integers n_i >= 1.
What about c(rep(2, N-2), 1, 1))?
but I'm afraid that this was not what you really wanted. ;-)
However, you didn't say if your sample should be random. :-)
Best regards -- Gerrit
---------------------------------------------------------------------
Dr. Gerrit Eichner Mathematical Institute, Room 212
gerrit.eichner using math.uni-giessen.de Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104 Arndtstr. 2, 35392 Giessen, Germany
http://www.uni-giessen.de/eichner
---------------------------------------------------------------------
Am 01.08.2019 um 12:27 schrieb Lorenzo Isella:
> Dear All,
> I cannot unfortunately provide any R code, otherwise I would not need to
> post this in the first place.
> I need to generate a sample of N positive non-zero integers such that
> their mean is *exactly* 2(N-1)/N, i.e. the mean depends on the length of
> the sample.
> For a start, we can assume that every integer in my sample can assume
> only the values 1, 2 and 3.
> Any suggestion is appreciated.
> Cheers
>
> Lorenzo
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list