如何从倒钟形曲线中采样 [英] how to sample from an upside down bell curve

查看:37
本文介绍了如何从倒钟形曲线中采样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下代码生成均匀分布的数字:

I can generate numbers with uniform distribution by using the code below:

runif(1,min=10,max=20)

如何对随机生成的数字进行采样,这些数字更接近最小和最大边界?(又名倒挂钟形曲线")

How can I sample randomly generated numbers that fall more frequently closer to the minimum and maxium boundaries? (Aka an "upside down bell curve")

推荐答案

嗯,钟形曲线通常是高斯曲线,这意味着它没有最小值和最大值.您可以尝试 Beta 分布 并将其映射到所需的间隔.沿线

Well, bell curve is usually gaussian, meaning it doesn't have min and max. You could try Beta distribution and map it to desired interval. Along the lines

min <- 1
max <- 20
q <- min + (max-min)*rbeta(10000, 0.5, 0.5)

正如@Gregor-reinstateMonica 所指出的,Beta 分布在两端都有界,[0...1],因此它可以很容易地通过缩放和移位映射到任何有界区间.它有两个参数,如果这些参数相等,则对称.超过 1 个参数使其成为一种钟形分布,但低于 1 个参数使其成为您正在寻找的反钟形分布.您可以使用它们,输入不同的值而不是 0.5,然后看看效果如何.参数等于 1 使其统一.

As @Gregor-reinstateMonica noted, Beta distribution is bounded on both ends, [0...1], so it could be easily mapped into any bounded interval just by scale and shift. It has two parameters, and symmetric if those parameters are equal. Above 1 parameters make it kind of bell distribution, but below 1 parameters make it into inverse bell, what you're looking for. You could play with them, put different values instead of 0.5 and see how it is going. Parameters equal to 1 makes it uniform.

这篇关于如何从倒钟形曲线中采样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆