Created
March 8, 2013 00:22
-
-
Save steko/5113167 to your computer and use it in GitHub Desktop.
simulating the time needed to look for sherd-links (joins)
This file contains 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
# simulating the time needed to look for sherd-links (joins) | |
# number of sherds | |
nos <- c(2^(4:16)) | |
# simplistic model: look for links between any two sherds | |
dx0 <- choose(nos, 2) | |
# first realistic model: look for links only between sherds | |
# of the same class, assuming 5 equally abundant classes | |
m1.class <- 5 | |
m1.fun <- function(n) sum(choose(rep(n%/%m1.class,m1.class), 2)) | |
dx1 <- sapply(nos, m1.fun) | |
# second realistic model: as model 1, but with uneven frequency | |
# of classes, roughly as observed in some real assemblages | |
m2.classes <- c(0.35, 0.30, 0.20, 0.10, 0.05) | |
m2.fun <- function(n) sum(choose(m2.classes * n, 2)) | |
dx2 <- sapply(nos, m2.fun) | |
# third realistic model: as model 2, but with random colors | |
# to help (e.g. you're not trying to link brown sherds with | |
# red ones | |
m3.classes <- m2.classes | |
m3.colors <- 2 | |
m3.fun <- function(n) sum(choose(m3.classes / m3.colors * n, 2) * m3.colors) | |
dx3 <- sapply(nos, m3.fun) | |
# realistic models have values of about one quarter and less with | |
# respect to the simplistic model, it is a "slow" exponential growth | |
plot(nos, dx0, ylog=TRUE) | |
points(nos, dx1, col="red") | |
points(nos, dx2, col="blue") | |
points(nos, dx3, col="green") | |
grid() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment