- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果您运行如下代码:
length(unique(runif(10000000)))
length(unique(rnorm(10000000)))
最佳答案
这主要是由于默认 PRNG 的属性(事实上,runif
的范围小于 rnorm
,因此即使 RNG 没有)。在 ?Random
中有些倾斜地讨论了它。 :
Do not rely on randomness of low-order bits from RNGs. Most of the supplied uniform generators return 32-bit integer values that are converted to doubles, so they take at most 2^32 distinct values and long runs will return duplicated values (Wichmann-Hill is the exception, and all give at least 30 varying bits.)
sum(duplicated(runif(1e6))) # around 110 for default generator
## and we would expect about almost sure duplicates beyond about
qbirthday(1 - 1e-6, classes = 2e9) # 235,000
RNGkind("Wich")
sum(duplicated(runif(1e6)))
[1] 0
sum(duplicated(runif(1e8)))
[1] 0
关于r - 为什么 runif() 的唯一值比 rnorm() 少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51425656/
(添加了可重现的示例。) 我对 rnorm 函数有点困惑。 我期待 mean(rnorm(100,mean=0,sd=1))为0;和 sd(rnorm(100,mean=0,sd=1))为 1。但给出
我正在调试我的模拟,我发现当我运行 rnorm() 时,我的随机法线值对我来说根本不是随机的。 ccc 是参数化给出的平均 sd 向量。我怎样才能获得真正随机的正常实现?由于我的原始模拟很长,我不想进
我想使用 rnorm() 创建随机变量在小标题的单独列中指定平均值和标准差 n % rowwise() %>% mutate(col_rnorm = list(setNames(rnorm(n,
rnorm 正在使用哪种算法函数默认生成标准正态分布的随机数? 最佳答案 见 ?RNGkind .默认是反演算法: normal.kind can be "Kinderman-Ramage", "Bu
我需要生成一个数据集,其中包含 3 个类中的 20 个观察值(每个类 20 个观察值 - 总共 60 个)和 50 个变量。我试图通过使用下面的代码来实现这一点,但是它抛出了一个错误,我最终创建了 5
早上好! 我正在寻找在 R 中创建一些代码的模拟 基本上,我有一个函数,除其他外,它采用用户提供的种子(默认为 NULL)以及特定分布(默认为 rnorm),并输出 9 个随机数,保存为向量“e”。这
如果您运行如下代码: length(unique(runif(10000000))) length(unique(rnorm(10000000))) 你会看到只有大约 99.8% 的 runif 值是
如何为 rnorm 的 mean 参数提供向量? around_int1_mean <- seq(1.5, 3.5, 0.1) 我想做类似rnorm(n=25, mean=around_int1_me
问题:这段代码究竟在做什么? 另外:“w”的使用方式是否是某种现有算法?我试图弄清楚函数的意图,或者至少描述它产生的数字种类。 上下文:我正在查看 Martin O'Leary 的“Fantasy M
我必须为大小为 N 的向量的两组生成随机数。 一组的概率为 p,另一组的概率为 q = 1-p。(例如,对于 p=0.5 的 1000 人,我必须从一个分布生成 500 个随机数,从另一个分布生成 5
以下代码的作用是: rnorm(10, mean=2, sd=1:10) 第一个数字来自 N(2,1) 第二个数字来自 N(2,2) 第三个数字来自 N(2,3) 等等...? 最佳答案 第一个参数告
我必须为大小为 N 的向量的两组生成随机数。 一组的概率为 p,另一组的概率为 q = 1-p。(例如,对于 p=0.5 的 1000 人,我必须从一个分布生成 500 个随机数,从另一个分布生成 5
我设置了种子,生成均匀分布的随机数,用逆CDF方法得到一组正态分布的随机数。然后,我重置种子并使用 rnorm() 生成正态分布的随机数.结果是不同的。 R 中的随机数生成器不是默认使用 Mersen
我将内置 R 函数 rnorm、qnorm 和 pnorm 的性能与等效的 Matlab 函数进行了比较。 似乎 rnorm 和 pnorm 函数在 R 中比在 Matlab 中慢 3-6 倍,而 q
我是一名优秀的程序员,十分优秀!