Field biologists run a field experiment over n days to assess the population of an invasor insect species.
An insect trap is set on the first day, and a new trap is added every day, so on the ith day, i traps are deployed. Each trap is expected to capture K individuals. However, specimens learn to avoid traps, so the effectiveness of the traps decays with time.
For this, the expected number of captured individuals on the i-th day is:
| Ei = |
|
Thus, the accumulated number of captures after n days of field work will be:
| C(n) = |
|
|
Write a function captures(n,K) that receives two integers: the number of days of the field experiment (n) and the expected captures per trap (K) and returns the expected accumulated number of captures C(n) at the end of the field experiment.
Observation
if __name__ == "__main__": conditional.
>>> captures(4,8) 21.333333 >>> captures(8,3) 8.154762 >>> captures(11,5) 13.591409 >>> captures(21,2) 5.436564 >>> captures(8,3) + captures(11,5) 21.746171