使用 stan 从偏态正态分布中绘制

draw from skew normal distribution using stan

有没有办法从 stan 中的偏态正态分布中提取数据?如果不是,有没有办法从正态分布中提取然后转换为偏斜正态分布?

更新

我在 stan 手册中找到了 y~skew_normal(mu, sigma, alpha),但是当我使用参数

对 1000 个值进行采样时

mu=1, sigma=10, alpha=-1000

我也得到了一些 -inf 值。有什么想法吗?

更新 2

我的testing.stan

data{
  real mu;
  real sigma;
  real alpha;
}
model{

}
generated quantities{
  real temp;

    temp = skew_normal_rng( mu,  sigma,  alpha);

}

然后是我的 testing.R 文件

sdata <- list(
  mu=1,
  sigma=10,
  alpha=-1000
)

 model <- stan_model("stan code//testing.stan")

system.time(
  samples  <- sampling(model,data=sdata,seed=42,
                       chain=1,algorithm="Fixed_param",
                       iter=10000,thin=1,control=list(max_treedepth=9)
  ) 
)

object <- rstan::extract(samples)
# hist(object$temp,breaks=100)
# plot(density(object$temp))
# mean(is.finite(object$temp))
# sum(!is.finite(object$temp))
sort(object$temp)

在 运行 sort(object$temp) 之后我得到一些 -inf 值。

运行这个型号:

parameters { real y; } model { y ~ skew_normal(1, 10, -1000); }

我没有得到无限抽奖。不过,我确实得到了很多分歧,这意味着数字不稳定。即使我降低初始步长并提高目标接受率也是如此。

使用 -10 而不是 -1000 的倾斜参数,这个问题就消失了。

可能有一些方法可以更改内部实现以提高极端偏斜值的稳定性,但是 -1000 在数值上肯定存在问题。