--- title: 'Illustration du problème de détection dans le modèle de bruit blanc' author: "`M2 Statistique, 2017-2018`" date: "Statistique mathématique en grande dimension et applications, cours de M. Roquain" output: html_document runtime: shiny --- ```{r, echo=FALSE} inputPanel( selectInput("m", label = "Number of hypotheses:", choices = c(1000 , 10000, 100000), selected = 10000), sliderInput("s", label = "Sparsity", min = 1, max = 1000, value = 5, step = 5), sliderInput("delta", label = "Signal strength:", min = 0.1, max = 8, value = 3, step = 0.5), actionButton("takeSample","Sample Now") ) rv <- reactiveValues(sample = 0, m = 10000 , s = 5, delta = 3) observeEvent(input$takeSample, { rv$sample <-rnorm(as.numeric(input$m)) rv$m=as.numeric(input$m) rv$s=as.numeric(input$s) rv$delta=as.numeric(input$delta) }) renderPlot({ m= rv$m s= rv$s delta= rv$delta xi=rv$sample if(input$takeSample){ theta=rep(0,m) theta[sample(1:m,s)]=(2*rbinom(s,1,1/2)-1)*delta Z=xi+theta pvalchi2=pchisq(sum(Z^2),m,lower.tail = FALSE) pvalmax=min(2*m*(1-pnorm(max(abs(Z)))),1) plot(Z,cex.axis=2,xlab="",ylab="",ylim=c(-7,7),col=gray(0.4),pch=19) lines(1:m,theta,col="lightsalmon",type="s",lwd=3) seuil=sqrt(2*log(m)) abline(h=-seuil,lwd=3,col="lightblue") abline(h=+seuil,lwd=3,col="lightblue") title(paste("pchi2=",signif(pvalchi2,2),", pmax=",signif(pvalmax,2)),cex.main = 2,col.main= gray(0.2)) } },height = 600, width = 1000) ```