#####R code f=c(0.5,0.5) n.al <- length(f) P.1 <- P.2 <- array(0,dim=rep(n.al,4)) for(a2 in 1:n.al) for(a1 in 1:n.al) for(a3 in 1:n.al) for(a4 in 1:n.al) { if (a1==a3 & a2==a4) { P.2[a1,a2,a3,a4] <- f[a1]*f[a2] P.1[a1,a2,a3,a4] <- f[a1]*f[a2]*(f[a1]+f[a2])/2 } if (a1==a3 & a2!=a4) { P.1[a1,a2,a3,a4] <- f[a1]*f[a2]*f[a4]/2 } if (a1!=a3 & a2==a4) { P.1[a1,a2,a3,a4] <- f[a1]*f[a3]*f[a2]/2 } } #####julia code f=Array(Float64,1,2) f[:,:]=0.5 p1=Array(Float64,nal,nal,nal,nal) p2=Array(Float64,nal,nal,nal,nal) p1[:,:,:,:]=0.0 p2[:,:,:,:]=0.0 for (a2 = 1:nal) for (a1 = 1:nal) for (a3 = 1:nal) for (a4 = 1:nal) if (a1==a3 & a2==a4) p2[a1,a2,a3,a4] = f[a1]*f[a2] p1[a1,a2,a3,a4] = f[a1]*f[a2]*(f[a1]+f[a2])/2.0 end if (a1==a3 & a2!=a4) p1[a1,a2,a3,a4] = f[a1]*f[a2]*f[a4]/2.0 end if (a1!=a3 & a2==a4) p1[a1,a2,a3,a4] = f[a1]*f[a3]*f[a2]/2.0 end end end end end
<https://lh3.googleusercontent.com/-V-fR1Z3wCS0/VbhSoLSjSjI/AAAAAAAAAAM/rNp8Wb1-wk8/s1600/Untitled.png>
#####R code f=c(0.5,0.5) n.al <- length(f) P.1 <- P.2 <- array(0,dim=rep(n.al,4)) for(a2 in 1:n.al) for(a1 in 1:n.al) for(a3 in 1:n.al) for(a4 in 1:n.al) { if (a1==a3 & a2==a4) { P.2[a1,a2,a3,a4] <- f[a1]*f[a2] P.1[a1,a2,a3,a4] <- f[a1]*f[a2]*(f[a1]+f[a2])/2 } if (a1==a3 & a2!=a4) { P.1[a1,a2,a3,a4] <- f[a1]*f[a2]*f[a4]/2 } if (a1!=a3 & a2==a4) { P.1[a1,a2,a3,a4] <- f[a1]*f[a3]*f[a2]/2 } } #####julia code f=Array(Float64,1,2) f[:,:]=0.5 p1=Array(Float64,nal,nal,nal,nal) p2=Array(Float64,nal,nal,nal,nal) p1[:,:,:,:]=0.0 p2[:,:,:,:]=0.0 for (a2 = 1:nal) for (a1 = 1:nal) for (a3 = 1:nal) for (a4 = 1:nal) if (a1==a3 & a2==a4) p2[a1,a2,a3,a4] = f[a1]*f[a2] p1[a1,a2,a3,a4] = f[a1]*f[a2]*(f[a1]+f[a2])/2.0 end if (a1==a3 & a2!=a4) p1[a1,a2,a3,a4] = f[a1]*f[a2]*f[a4]/2.0 end if (a1!=a3 & a2==a4) p1[a1,a2,a3,a4] = f[a1]*f[a3]*f[a2]/2.0 end end end end end