繁体   English   中英

我在 "}"'' 中收到错误 'Error: unexpected '}' 。 我的括号在哪里放错了?

[英]I am getting the error 'Error: unexpected '}' in " }"'' . Where are my brackets misplaced?

N <- 10000 ; 
one_side_normal <- function(N) {
  f <- numeric(N);
  for (i in 1:N) {
    X = rexp(1,rate=1);
    uniform = runif(1);
    while (uniform>exp((-X^2)+X) {
      X = rexp(1,rate=1);
      uniform=runif(1);
    }
    f[i] <- X
  }
  return(f)
}

我的代码在上面。 我正在尝试使用接受拒绝方法从一侧正态分布生成 10000 个随机样本。 你能强调一下我括号里的错误在哪里吗?

while步骤缺少右括号

 ...
 while (uniform>exp((-X^2)+X) )   {
                              ^
 ...

暂无
暂无

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

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