bayesAPI = function (){ require(tcltk); t=seq(0,1,0.001); nmax <- 5000; theta=0.3; y <<- as.integer(runif(nmax)=1) {lines(mean(y[1:nn]), 0, type="p", pch="o", cex=3, col="green");} } tkconfigure(nValueLabel, text=as.character(nn)); tkconfigure(aValueLabel, text=as.character(aa)); tkconfigure(bValueLabel, text=as.character(bb)); tkconfigure(thetaValueLabel, text=as.character(theta)); } otherPlot <- function(...){ init(); controlPlot(); } nSlider <- tkscale(nFrame, from=0, to=nmax, length=600, showvalue=F, variable=n, resolution=1, orient='horizontal', command=controlPlot) tkpack(nFrame, nLabel, nValueLabel, nSlider, side='left'); aSlider <- tkscale(aFrame, from=1, to=500, length=600, showvalue=F, variable=a, resolution=1, orient='horizontal', command=controlPlot) tkpack(aFrame, aLabel, aValueLabel, aSlider, side='left'); bSlider <- tkscale(bFrame, from=1, to=500, length=600, showvalue=F, variable=b, resolution=1, orient='horizontal', command=controlPlot) tkpack(bFrame, bLabel, bValueLabel, bSlider, side='left'); thetaSlider <- tkscale(thetaFrame, from=0, to=100, length=600, showvalue=F, variable=theta, resolution=1, orient='horizontal', command=otherPlot) tkpack(thetaFrame, thetaLabel, thetaValueLabel, thetaSlider, side='left'); tkpack(sliderFrame, nFrame, aFrame, bFrame, thetaFrame, side='top') btfrm <- tkframe(tt, borderwidth=2,relief='groove') rbdemo <- tkradiobutton(btfrm, command=controlPlot, text='demo', variable=mode) rbexp <- tkradiobutton(btfrm, command=controlPlot, text='exp', variable=mode) tkconfigure(rbdemo, variable=mode, value='demo'); tkconfigure(rbexp, variable=mode, value='exp'); rbdens <- tkradiobutton(btfrm, command=controlPlot, text='dens', variable=visu) rbnorm <- tkradiobutton(btfrm, command=controlPlot, text='norm', variable=visu) tkconfigure(rbdens, variable=visu, value='demo'); tkconfigure(rbnorm, variable=visu, value='exp'); tkpack(btfrm, rbdemo, rbexp, tklabel(btfrm, text=" "), rbdens, rbnorm, side='left') btReset <- tkbutton(tt, command=otherPlot, text='Reset'); tkpack(tt, btfrm, sliderFrame, btReset, side='top'); } bayesAPI();