You are on page 1of 1

x<-c()

maxIter=50
succ_prob=0.5
for (i in 1:maxIter){
a <- table(rbinom(50,1,succ_prob))
y<-(a[2]/50)
x<-c(x,y)

}
print("estimated p:")
print(x)
print("estimated mean:")

mean(x)
print("estimated var:")

var(x)
hist(x)

You might also like