You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
meibujun
changed the title
why do I change R code to julia code, but I have different result.
What reason different result, when I change R code to julia code? Thank you
Jul 29, 2015
meibujun
changed the title
What reason different result, when I change R code to julia code? Thank you
What reason is different result, when I change R code to julia code? Thank you
Jul 29, 2015
R code
julia code
The text was updated successfully, but these errors were encountered: