Help us understand the problem. What is going on with this article?

Approximation theorems of mathmatical statics


#Approximation theorems of mathmatical statics p.64

#cramer-von Mises test

library(dplyr);library(mvnorm)

n=10000

x=rbinom(n, size=50, prob=0.3)

values=sort(unique(x))

data=data.frame(values=values,Fn=0,F=0,f=0,fn=0)

for(j in 1:length(values)){

data$Fn[j]=sum(x<data$values[j])/n

data$F[j]=ppois(data$values[j],50*0.3)

data$f[j]=dpois(data$values[j],50*0.3)

#sample density functions(bn=1/log(n))

data$fn[j]=(sum(x<data$values[j]+1/log(n))/n-sum(x<data$values[j]-1/log(n))/n)/(2/log(n))

}

C_n=n*sum(data$f*(data$Fn-data$F)^2)

#using theorem A(Finkelstein)

epsilon=0.00001

under=C_n-(1+epsilon)*(2*log(log(n)))/(pi^2)

upper=C_n+(1+epsilon)*(2*log(log(n)))/(pi^2)


#p.68 2.2.2

n=10000

mu=2

x=rnorm(n,mu,1)

b=c()

mu2=c()

k=10

for(j in 1:k){

b=c(b,sum((x-mu)^j)/n)

mu2=c(mu2,sum((x-mu)^(2*j))/n)

}

#V(bk)

(mu2-b^2)/n

cov_mat=array(0,dim=c(k,k))

for(i in 1:k){
for(j in 1:k){

cov_mat[i,j]=(sum((x-mu)^(i+j))/n-sum((x-mu)^i)*sum((x-mu)^j)/(n^2))/n

}}

(rmvnorm(100,b,cov_mat),2,mean)

kozakai-ryouta
自身で実装することに生きがいを感じています。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away