N <- 10
L <- 4
poly<-c()
for(i in 1:L){poly[i]<-sample(2:4,1)}
A<-array(0,c(2,L,N))
for(n in 1:N){
for(i in 1:2){
for(l in 1:L){
A[i,l,n]<-sample(1:poly[l],1)
}}}
while(N < 100){
hap1<-hap2<-c()
select<-sample(1:N,2)
for(l in 1:L){
hap1[l]<-sample(A[,l,1],1)
hap2[l]<-sample(A[,l,2],1)
}
A<-array(c(A,hap1,hap2),c(2,L,N+1))
N<-dim(A)[3]
V<-c()
for(n in 1:N){
for(i in 1:2){
num<-poly%*%A[i,,n]
V<-c(V,num)
}}
}
hist(V)
Nmax <- 2000
N<-100
L <- 20
poly<-c()
poly<-rep(3,length=L)
A<-array(0,c(2,L,Nmax))
for(n in 1:N){
for(i in 1:2){
for(l in 1:L){
A[i,l,n]<-sample(1:poly[l],1)
}}}
A[,,N]
for(n in (N+1):Nmax){
select<-sample(1:(n-1),2)
for(l in 1:L){
A[1,,n]<-sample(A[,l,select[1]],1)
A[2,,n]<-sample(A[,l,select[2]],1)
}
}
V<-c()
for(n in 1:Nmax){
for(i in 1:2){
num<-poly%*%A[i,,n]
V<-c(V,num)
}}
hist(V)
length(V)