I have two matrices Ac and Ep and a parameter k. I need to implement this matrix, which is a function of my prior matrices and k :
ProbEnt(k)[i,j] := if (k < wmax) then binomial(Ac[i,j], k)*Ep[i,j]^k * (1-Ep[i,j])^(Ac[i,j]-k) else 0;
For some reason it will not allow me to define (build) ProbEnt parameter-wise. Is there a way to make this work?
Looks like the function genmatrix
might work for you. The first argument of genmatrix
is a function which takes two arguments, i
and j
, which you can use to define the i, j
element you want.
In this case it might be something like
myfunction (i, j) := if k < wmax then <stuff about Ac and Ep here> else 0);
genmatrix (myfunction, mm, nn);
where mm
and nn
are the numbers of rows and columns you want.