Created
May 16, 2013 23:05
-
-
Save Ram-N/5595795 to your computer and use it in GitHub Desktop.
How to count number of fish in an odd shaped pond?
The Capture-Mark-Recapture technique of estimation
Let’s say that we first captured 80, marked them and released them back. (m=80)
A few days later, catch 60 (n=60) [sample set]
13 of them are from m. (k=13)
N-hat : 80 = 60:13
Okay, very clever. But how good is this estimate?
Bootstrapping can g…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BigN<- NULL # BigN is the DISTRIBUTION of N.hats | |
m <- 80 # initial number of fish that we caught and marked and released | |
n <- 60 # the fish that were caught again. Our "sample” | |
for(i in 1:5000) { | |
s <- sample.int(n, replace=T) #resampling from our second captured set | |
k <- sum(s<14) # how many of them were the marked ones | |
N.hat <- (m * n)/k | |
BigN <- c(N.hat, BigN) | |
} | |
# Let's inspect what we got | |
library(ggplot2) | |
ggplot() + geom_histogram(aes(BigN), binwidth=25) | |
#Explore | |
mean(BigN) | |
summary(BigN) | |
sd(BigN) | |
t.test(BigN) # Confidence Interval for the Mean | |
wilcox.test(BigN, conf.int=TRUE) #confidence Interval for the Median | |
median(BigN) #Note that it is different from the Wilcox (pseudo-Mean) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment