f<-function(x,sigma=0.84,theta=1.12){
sqrt(2/pi)*(theta/x)*(x*sigma)^theta*exp(-(x*sigma)^(2*theta)*(1/2))
}
rf<-function(f,n,sigma,theta,N=500){
df<-seq(1,50,length.out=N)
p<-f(df,sigma,theta)
p<-p/sum(p)#正则化
sample(df,size=n,replace=F,prob=p)
}
x=matrix(rep(1,s*n),nrow=s,ncol=n)
xcensor=matrix(rep(1,s*r),nrow=s,ncol=r)
for (k in 1:s){
x[k,]=rf(f,n,sigma,theta)
xcensor[k,]= sort(x[k,])[1:r]
}
为什么产生的随机数每一行都一样


雷达卡


京公网安备 11010802022788号







