Thank, Claudio!
It works on this small data set, but not on the real one, unfortunately...
It's a data set about fishing (joined).
We need first routines to estimate the second parameter (probability of success) of a negative binomial (or Pascal, in my case) distribution:
ClearAll["Global`*"];
Place = NotebookDirectory[];
SetDirectory[Place <> "/Données"];
\[Epsilon] = 10^-6;
Brut = Import["Peches2005.xlsx", {"Dataset", 1}, HeaderLines -> 1];
pEstPonct[temps_, fish_] :=
If[N@fish <= 1 + \[Epsilon],
0, (fish - 1)/(temps + fish - 1)]; (* Haldane; 1945, Sahai; 1979 *)
pEstGroup[temps_, fish_ /; fish >= 1] :=
Block[{freq, \[Theta], x, fx, p},
freq = Tally[temps];
x = First@Transpose@freq;
fx = Last@Transpose@freq;
\[Theta] = (x.fx)/((x.fx) + fish Total@fx - 1);
p = (1 - \[Theta]);
N[p]
]
Then, the sub-dataset associated with trouts (coded "TRF") is extracted:
Cherche = "TRF";
Lepoisson = Brut[Select[#"nom_sp" == Cherche &]];
Now, estimation of the probability (2 methods); Diff denotes the time spent, nb (the variable "Total" , an unfortunate coding) the number of fishes; Pas is the time unit.
Pas = 4; (* Unité de temps, en minutes : temps entre deux actes \
de pêche (lancers,...) *)
Diff = Flatten@
Normal@Lepoisson[
All, {N[(AbsoluteTime@#"hcont" -
AbsoluteTime@#"hdeb") (1/(60 Pas))] &}];
nb = Lepoisson[All, {"Total"}];
Paire = Dataset@
Join[{Join[Keys@nb[[1]], {"Diff"}]},
Table[Join[(Keys@nb[[1]] /. nb)[[y]], {Diff[[y]]}], {y,
Length@Diff}]];
Head@Paire
"Paire" denotes the pair (total, Diff), built with your method. It seems correct but, for some reason, the following instructions don't work:
Paire = Select[Paire, #Diff > 0 &];
Length@Paire
Paire = Select[Paire, #Total =!= "" &];
Length@Paire
Any idea?
Claude
Attachments: