#0: # Experiment zur Abschaetzung von p per Intervall. source(file="http://www.wiwi.uni-bielefeld.de/~wolf/software/R-wtools/slider/slider.R") p.est<-function(){ refresh.code<-function(...){ # Vorbereitung p<-slider(no=1)/100; n<-slider(no=2); kk<-slider(no=3); zz<-slider(no=4) set.seed(zz) x<-1:n; res<-rbinom(n,1,p) f.x<-cumsum(res)/x k<-1/(1-kk)^0.5 delta<-k*0.5/sqrt(1:n) ug<-f.x-delta; og<-f.x+delta # plot plot(x,f.x,xlim=c(1,n),ylim=0:1,xlab="n",ylab="Intervall",type="l",log="x",bty="n") title(paste("p mit Mittel einfangen\np=",p,", Sicherheit=",kk,", Zufall=",zz,sep="")) abline(h=p,col="red") lines(x,ug); lines(x,og) } slider(refresh.code, c("p*100 Erfolgsprozentsatz","n Experimentumfang","1-1/k^2 Sicherheit", "Zufallsstart"), c(1,1,0.01,1),c(99,5001,.99,999),c(1,50,0.01,1),c(50,2000,.9,7) ) } #:0 #3: p.est() #:3