i have this function for computing a probability
function probability(eta,pdc,x::Array,y::Array)
P=[]
for k in 1:length(y)
if y[k]==0
push!(P,(1-pdc)*(1-eta*(1-pdc))^x[k])
elseif y[k]==1
push!(P,1-(1-pdc)*(1-eta*(1-pdc))^x[k])
end
P_iDC=prod.(P[2:end-2])
P_DC=sum.(P_iDC)
P_iECDC=prod.(P)
P_ECDC=sum.(P_iECDC)
print(P_ECDC./P_DC)
end
end
probability(0.05,1e-5,[1,0,1,1,0,1,0,1],[1,1,0,0,1,0,0,0])
when the function is called it shows me this error that i don’t know really how to fix it:
Any[]
DimensionMismatch("arrays could not be broadcast to a common size")
Stacktrace:
[1] _bcs1 at ./broadcast.jl:485 [inlined]
[2] _bcs at ./broadcast.jl:479 [inlined]
[3] broadcast_shape at ./broadcast.jl:473 [inlined]
[4] combine_axes at ./broadcast.jl:468 [inlined]
[5] instantiate at ./broadcast.jl:256 [inlined]
[6] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(/),Tuple{Array{Float64,1},Array{Any,1}}}) at ./broadcast.jl:798
[7] probability(::Float64, ::Float64, ::Array{Int64,1}, ::Array{Int64,1}) at ./In[81]:15
[8] top-level scope at In[81]:18
from the error message the error is in this line
print(P_ECDC./P_DC)
but i don’t know the way to fix it