[R] generate a vector of random numbers within confines of certain parameters

Bert Gunter bgunter.4567 at gmail.com
Tue Aug 2 23:01:43 CEST 2016


All floating point operations are done to machine precision -- roughly
16 digits. See ?.Machine . You can choose to round, truncate, or
display to anything less than that that you care to. See also the
digits parameter of  ?options

The rest of your post is ambiguous to me. But note that (all?/most?)
rng's are vectorized, so e.g.

> set.seed(1123)

> rnorm(10,mean= runif(10,2,3), sd = runif(10,4,6))

 [1]  4.369411  1.944876  3.143913  6.489048 -1.093468  1.330675
-3.936239 11.740755
 [9] -2.260413 -1.748759

... if that's what you meant.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Aug 2, 2016 at 11:56 AM, Adrian Johnson
<oriolebaltimore at gmail.com> wrote:
> Dear group,
>
> I am trying to generate a vector of random numbers for 20K observation.
>
> however, I want to generate numbers (with 6 decimal places) within the range of
> Std. Dev : 2-3
> mean  : 4-6
>
> Is there a method to generate numbers with 6 decimal places under
> these parameters
>
> thank you.
> Adrian
>
> ______________________________________________
> R-help at 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