简体   繁体   English

R中具有均匀分布元素的随机向量a

[英]Random vector a with elements from the uniform distribution in R

I'm new to R and I'm looking through a book called "Discovering Statistics using R". 我是R的新手,正在翻阅一本名为“使用R发现统计信息”的书。

Although the book implies you don't need any statistical background, some of the content isn't covered/explained... 尽管这本书暗示您不需要任何统计背景,但其中一些内容并未涵盖/解释...

I'm wondering how you simulate a random vector a with 200 elements from the uniform distribution on the interval (-50, 50). 我想知道如何从间隔(-50,50)的均匀分布中模拟一个具有200个元素的随机向量a。

Maybe I'm unsure because of the terminology used. 也许由于使用的术语我不确定。 For the example I just created a vector with 200 elements that range inbetween -50 and 50... I'm just checking if this is correct. 对于该示例,我刚刚创建了一个向量,该向量包含200个元素,其范围在-50到50之间...我只是检查这是否正确。

Or is there a function that generates random values like there is in Java? 还是有一个函数可以像Java中那样生成随机值? I haven't found anything on google either regarding R providing random values. 关于R提供随机值,我也没有在Google上找到任何东西。

runif(200, -50, 50)

会成功的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM