科学的数字处理

发布于 2024-12-03 21:16:28 字数 1682 浏览 1 评论 0原文

我正在使用包 qvalue,它具有以下预处理步骤,

 if(min(p)<0 || max(p)>1) {
    print("ERROR: p-values not in valid range"); return(0)
    }
    if(length(lambda)>1 && length(lambda)<4) {
    print("ERROR: If length of lambda greater than 1, you need at least 4 values."); return(0)
    }
    m <- length(p)

我有 6000 个值,如下所示: 由于溢出的字符限制,我可以显示它们

[1] 0.3671178710 0.9360140780 0.2428194940 0.5185496048 0.3280692392
   [6] 0.4681617243 0.3654880576 0.3121728291 0.6357866236 0.2576397417
  [11] 0.7224965457 0.4020649535 0.1359902232 0.4313780172 0.7543924642
  [16] 0.1915732183 0.4359938726 0.2705147307 0.5155629834 0.4446611542
  [21] 0.6636414268 0.4666097886 0.5121170670 0.7911474854 0.0662147755
  [26] 0.8659648750 0.0307181717 0.0910574293 0.7331402271 0.3078877515
  [31] 0.8331673742 0.4992904913 0.0773711040 0.6134791426 0.6714738843
  [36] 0.6620106441 0.3944466498 0.3330491388 0.7726571107 0.5989331217
  [41] 0.4429749257 0.7650029317 0.7608016901 0.3642432987 0.1672484189
  [46] 0.4305554981 0.4308085746 0.7999056710 0.8117493501 0.3325086551
  [51] 0.7233274303 0.4939756680 0.7763859166 0.8281922847 0.5195117763
  [56] 0.6581468025 0.7082172344 0.7201224910 0.8420571108 0.3118079731
  [5996] 0.3066819785 0.6066206806 0.7524323861 0.6815655815 0.7105895186

每当我为该变量使用函数时: fdrq = qvalue(as.numeric( nd[,3]), fdr.level = 0.05 )

我收到错误:

[1] "ERROR: p-values not in valid range"

我试图查看最大值和最小值,看起来它在范围内。

> max(nd[,3])
[1] 1
> min(nd[,3])
[1] 0.0001641695

请提供可能存在问题的建议!这是处理十进制数的特殊方法吗……或者这是一个错误……

谢谢;

I am using package qvalue which has the following pre-processing step

 if(min(p)<0 || max(p)>1) {
    print("ERROR: p-values not in valid range"); return(0)
    }
    if(length(lambda)>1 && length(lambda)<4) {
    print("ERROR: If length of lambda greater than 1, you need at least 4 values."); return(0)
    }
    m <- length(p)

I have 6000 values like the following: I could show them due to character limit of the overflow

[1] 0.3671178710 0.9360140780 0.2428194940 0.5185496048 0.3280692392
   [6] 0.4681617243 0.3654880576 0.3121728291 0.6357866236 0.2576397417
  [11] 0.7224965457 0.4020649535 0.1359902232 0.4313780172 0.7543924642
  [16] 0.1915732183 0.4359938726 0.2705147307 0.5155629834 0.4446611542
  [21] 0.6636414268 0.4666097886 0.5121170670 0.7911474854 0.0662147755
  [26] 0.8659648750 0.0307181717 0.0910574293 0.7331402271 0.3078877515
  [31] 0.8331673742 0.4992904913 0.0773711040 0.6134791426 0.6714738843
  [36] 0.6620106441 0.3944466498 0.3330491388 0.7726571107 0.5989331217
  [41] 0.4429749257 0.7650029317 0.7608016901 0.3642432987 0.1672484189
  [46] 0.4305554981 0.4308085746 0.7999056710 0.8117493501 0.3325086551
  [51] 0.7233274303 0.4939756680 0.7763859166 0.8281922847 0.5195117763
  [56] 0.6581468025 0.7082172344 0.7201224910 0.8420571108 0.3118079731
  [5996] 0.3066819785 0.6066206806 0.7524323861 0.6815655815 0.7105895186

Whenever I fun the function for this variable:
fdrq = qvalue(as.numeric( nd[,3]), fdr.level = 0.05 )

I am getting error:

[1] "ERROR: p-values not in valid range"

I tried to see the maximum and minimum, looks like it is in range.

> max(nd[,3])
[1] 1
> min(nd[,3])
[1] 0.0001641695

Please provide suggestion on what might be wrong ! is this something special on handling of decimal numbers ..... or this is a bug ...

Thanks;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黯淡〆 2024-12-10 21:16:28

我怀疑您有一个比 1 稍大一点的值,但它被打印为“1”:

> x <- 1.000000000000001
> x
[1] 1
> x > 1
[1] TRUE

您可以配置 R 以显示更多数字:

> options(digits=20)
> x
[1] 1.000000000000001

一个简单的解决方法可能是强制所有大于 1 的值恰好为 1.0:

> x <- c(1, 0.7, 1.000000000000001, 0.3, 0)
> x
[1] 1.000000000000000 0.700000000000000 1.000000000000001 0.300000000000000
[5] 0.000000000000000
> x[x>1] <- 1
> x
[1] 1.0 0.7 1.0 0.3 0.0

< strong>我不知道这种解决方法对于您的情况是否明智。

I suspect that you have a value that's a tiny bit greater than 1, but that gets printed as "1":

> x <- 1.000000000000001
> x
[1] 1
> x > 1
[1] TRUE

You can configure R to display more digits:

> options(digits=20)
> x
[1] 1.000000000000001

A simple workaround might be to force all values greater than 1 to exactly 1.0:

> x <- c(1, 0.7, 1.000000000000001, 0.3, 0)
> x
[1] 1.000000000000000 0.700000000000000 1.000000000000001 0.300000000000000
[5] 0.000000000000000
> x[x>1] <- 1
> x
[1] 1.0 0.7 1.0 0.3 0.0

Whether this workaround is a sensible thing to do in your case, I don't know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文