(* Capture Recapture History *)
myCHcc[K_] := Table[IntegerDigits[n, 2, K], {n, 1, 2^K - 1}]
(* Capture Recapture Probability *)
myindprobCC[CH_]:=Module[{K,ind,fi,li,d,ans},
(* Get $K$ *)
K = Length[ CH ];
(* None Zero Positions *)
ind = Position[ CH, _?(# != 0 &) ];
fi = ind[[1]][[1]];
li = ind[[-1]][[1]];
(* Get probabilities *)
ans =
Sum[
Product[ Subscript[\[Phi], j], {j, fi, d - 1}]
*
(1 - Subscript[\[Phi], d])
*
Product[
Subscript[p,j]^CH[[j]]
*
(1-Subscript[p,j])^(1 - CH[[j]]),
{j, fi + 1, d}
],
{d, li, K}
]
]
xij = myCHcc[3]
ans = Map[myindprobCC, xij]
I have been a long time Maple user, so sorry if the questions are a bit basic.
Now,how I do get all the parameters in “ans”?
What I hope to have is a derivative matrix (Jacobian) from the vector “ans”.
In Maple, there is a function called “indets”
http://www.maplesoft.com/support/help/Maple/view.aspx?path=indets
So, quickly, I can apply the “D” fucntion to the “ans” with respect to the “parameters”.
Is there a similar function in Mathematica?
This is just a simple “ans” that I am testing, so the solution from an earlier post for me
https://wolfram.discourse.group/t/1791/1
does not work in this case.
Also, just a side to this piece of code,
is there a “proper” way to get the integer from the line
fi = ind[[1]][[1]];
the [[1]][[1]] seems “unnecessary” to me. So I wonder is this the correct way to do it.
Thanks,