作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是R的新手,并且需要有关如何从参数s和beta的帕累托分布的有限区域中抽取随机数的建议。 (系统:Windows 7,R 2.15.2。)
(1)我在向量data $ t中有数据;每个数据点我都会称之为data&tx
对于这些数据,根据https://stats.stackexchange.com/questions/27426/how-do-i-fit-a-set-of-data-to-a-pareto-distribution-in-r估计帕累托分布的参数s&beta
pareto.MLE <- function(X)
{
n <- length(X)
m <- min(X)
a <- n/sum(log(X)-log(m))
return( c(m,a) )
}
最佳答案
从截断的分布中采样的标准方法包括三个步骤。这是一个具有正态分布的示例,因此您可以理解。
n <- 1000
lower_bound <- -1
upper_bound <- 1
(quantiles <- pnorm(c(lower_bound, upper_bound)))
# [1] 0.1586553 0.8413447
uniform_random_numbers <- runif(n, quantiles[1], quantiles[2])
truncated_normal_random_numbers <- qnorm(uniform_random_numbers)
ppareto <- function(x, scale, shape)
{
ifelse(x > scale, 1 - (scale / x) ^ shape, 0)
}
qpareto <- function(y, scale, shape)
{
ifelse(
y >= 0 & y <= 1,
scale * ((1 - y) ^ (-1 / shape)),
NaN
)
}
n <- 1000
scale <- 1
shape <- 1
lower_bound <- 2
upper_bound <- 10
(quantiles <- ppareto(c(lower_bound, upper_bound), scale, shape))
uniform_random_numbers <- runif(n, quantiles[1], quantiles[2])
truncated_pareto_random_numbers <- qpareto(uniform_random_numbers, scale, shape)
rpareto <- function(n, scale, shape, lower_bound = scale, upper_bound = Inf)
{
quantiles <- ppareto(c(lower_bound, upper_bound), scale, shape)
uniform_random_numbers <- runif(n, quantiles[1], quantiles[2])
qpareto(uniform_random_numbers, scale, shape)
}
关于r - 从受限制的帕累托分布中抽取随机数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14497349/
我确信一定有什么东西可以为我做到这一点。 我有一个显示项目列表的网络用户界面。如果你点击一个项目,会发生两件事: UI 将使用立即可用的信息进行更新,然后将发出异步请求以获取更多信息。完成后,它将更新
我是一名优秀的程序员,十分优秀!