UNPKG

mark-and-recapture

Version:

A set of mark and recapture estimator functions based on Lincoln-Peterson/Chapman/Bayesian methods.

28 lines (25 loc) 1.23 kB
'use strict'; //https://en.wikipedia.org/wiki/Mark_and_recapture Object.defineProperty(exports, "__esModule", { value: true }); var estimate = function estimate(capInital) { return function (capCurrent) { return function (capIntersection) { //https://en.wikipedia.org/wiki/Lincoln_index var lincolnIndex = Math.trunc(capInital * capCurrent / capIntersection); //https://en.wikipedia.org/wiki/Lincoln_index var chapmanIndex = Math.trunc((capInital + 1) * (capCurrent + 1) / (capIntersection + 1) - 1); //https://en.wikipedia.org/wiki/Mark_and_recapture#Bayesian_estimate var basyesianEstimateMean = Math.trunc((capInital - 1) * (capCurrent - 1) / (capIntersection - 2)); var basyesianEstimateStandardDeviation = Math.sqrt((capCurrent - 1) * (capInital - 1) * (capCurrent - capIntersection + 1) * (capInital - capIntersection + 1) / ((capIntersection - 2) * (capIntersection - 2) * (capIntersection - 3))); return { lincolnIndex: lincolnIndex, chapmanIndex: chapmanIndex, basyesianEstimate: basyesianEstimateMean, basyesianEstimateStandardDeviation: basyesianEstimateStandardDeviation }; }; }; }; exports.estimate = estimate;