简体   繁体   English

最小样本量n,以使差异不超过

[英]Minimum sample size n such that difference is no more than

What is the minimum sample size n (or the length n = length(x) of the data vector x ) such that the difference D = 1 - statx4(x)/statx5(x) of the functions statx4 and statx5 is no more than 1/100 ie D ≤ 1/100 ? 最小样本大小n (或长度n =数据向量x的 length(x))的最小大小是多少,以使得差D = 1-函数statx4和statx5的statx4(x)/ statx5(x)不大于1/100,D≤1/100

And here are the functions: 这里是函数:

statx4 <- function(x)  {
  numerator <- sum((x-mean(x))^2)
  denominator <- length(x)
  result <- numerator/denominator
  return(result)
}
statx5 <- function(x)  {
  numerator <- sum((x-mean(x))^2)
  denominator <- length(x)-1
  result <- numerator/denominator
  return(result)
}

I've been doing this exercise set for a while, but haven't managed to get anything valid on this question. 我已经进行了一段时间的练习,但是在这个问题上没有任何有效的方法。 Could you point me to right direction? 你能指出我正确的方向吗?

For the normal distribution, it is the following: 对于正态分布,如下所示:

  statx4 <- function(x)  {
  numerator <- sum((x-mean(x))^2)
  denominator <- length(x)
  result <- numerator/denominator
  return(result)
}
statx5 <- function(x)  {
  numerator <- sum((x-mean(x))^2)
  denominator <- length(x)-1
  result <- numerator/denominator
  return(result)
}

D <- function(x){

  1-statx4(x)/statx5(x)
}


DD <- function(N=1111,seed =1){
  set.seed(seed)
  Logi <- vector()
  for (n in 1:N) {
    x<- rnorm(n)
    y <- D(x)
    Logi[n] <- (y  > 1/100) 
  }
  return(Logi)
}

 min  <- vector()
 for (seed in 1:100) {
   message(seed)
   DD(1000,seed)
   min[seed] <-  length(which(DD(1000) == TRUE))
 }

  Answer <- mean(min)+1
Answer 

Note that the function D evaluates the difference of the unbiased variance and the ordinal variance. 注意,函数D评估无偏方差和有序方差的差。

I think this problem should be more clear in mathematical sense. 我认为这个问题在数学上应该更清楚。

I got solutions today and all you had to do was guess random values: 今天我有了解决方案,您所要做的就是猜测随机值:

a <- rnorm(99); 1-statx4(a)/statx5(a)
a <- rnorm(100); 1-statx4(a)/statx5(a)
a <- rnorm(101); 1-statx4(a)/statx5(a)`

And correct answer is 100. 正确答案是100。

Thank you all for help. 谢谢大家的帮助。

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

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