Statistik-Laborstepfunts1Limit<-Limit[1] Einsatz<-Einsatz[1] Kapital<-Kapital[1] Anzahl<-Anzahl[1] pair<-seq(2,36,by=2) impair<-seq(1,35,by=2) rouge<-c(1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,35) noir<-c(2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35) manque<-c(1:18) passe<-c(19:36) # Initialisierung des Setzens satz<-Einsatz satzhoehe<-Einsatz a<-Coup # Zuordnen der gesetzten Chance { if(a=="pair") { satz<-pair } else if (a=="impair") {satz<-impair } else if (a=="rouge") {satz<-rouge} else if (a=="noir") {satz<-noir } else if (a=="manque") {satz<-manque} else if (a=="passe") {satz<-passe} else if (! all(a%in%c(0:36)) ) stop(message="Fehler in Coup") } satzhoehe <- Einsatz verlauf <- satzhoehe it<-0 saldo<-0 while(satzhoehe>0 & satzhoehe<=Limit & ((Kapital+saldo[it+1])>=satzhoehe) & it<Anzahl) { it<-it+1 verlauf <- append(verlauf,satzhoehe) coup<-floor(runif(1,min=0,max=37)) # Werfen der Kugel gewinn<-0 if (coup%in%satz) # Bestimmen ob Gewinn { gewinn <- 1 saldo <- append(saldo,saldo[length(saldo)]+satzhoehe) } if (coup==0 ) { saldo <- append(saldo,saldo[length(saldo)]-0.5*satzhoehe) } if (coup!=0 & gewinn==0 ) { saldo <- append(saldo,saldo[length(saldo)]-satzhoehe) } } yl<-c(min(c(saldo,verlauf,0)),max(c(verlauf,saldo,0))) plot(c(1:it)+.5,saldo[2:length(saldo)],type="b",col="red",ylim=yl,lwd=2, xlab="Coup-Numer",ylab="",sub=paste("Anfangskapital:",as.character(Kapital))) lines(c(1,it),rep(Einsatz,2),col="green") lines(c(1:it),verlauf[2:length(verlauf)],type="b",col="blue",lwd=2) lines(c(1,it),rep(0,2)) title("Masse égale: Saldo (rot) und Einsatzhöhe (blau)") 1{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fswiss\fprq2\fcharset0 Verdana;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\f0\fs24 Anfangskapital: @(print(Kapital)) \par Anzahl Coups : @(print(it)) \par Endkapital : @(print(saldo[length(saldo)]+Kapital)) \par \par \par } 1Datensatz(D11)1"pair"10000101pair100001010020