Package 'birthdayproblem'

Title: Functionality for handling the birthday problem with unequal probabilities
Description: The package contains a simple function for computing the probability that in a group of n people, with ppl originating from one of N classes, that two or more people in the group are of the same class.
Authors: Michael Höhle [aut, cre]
Maintainer: Michael Höhle <[email protected]>
License: GPL-3
Version: 0.0.0.9000
Built: 2024-11-14 03:43:03 UTC
Source: https://github.com/mhoehle/birthdayproblem

Help Index


Variant of pbirthday, which handles unequal occurrence probabilites

Description

This function calculates the probability for at least one collision in a set of n individuals sampled iid. from a vector of length N with occurrence probabilities as given by the vector p. This is an instance of the birthday problem with unequal occurrence probabilities.

Usage

pbirthday_up(n, prob, method = c("R", "Rcpp", "mase1992"))

Arguments

n

Size of the set

prob

Vector containing the occurrence probabilities. The length of prob determines N.

method

A string describing which computational method to use. "R" (the default) works in acceptable time up to n's of about 30. The "Rcpp" options works for larger n of moderate size, e.g., n=60 takes about 3 minutes. For larger n or faster computation one can use the "mase1992" approximation, which is surprisingly accurate.

Value

A list containing the following elements:

prob

(numeric) The probability for at least one collision

tList

A matrix containing all compositions of singletons, dubletons, each row has the property sum(row * 1:n) == n.

...

References

Mase, S. 1992. “Approximations to the Birthday Problem with Unequal Occurrence Probabilities and Their Application to the Surname Problem in Japan.” Ann. Inst. Stat. Math. 44 (3): 479–99. http://www.ism.ac.jp/editsec/aism/pdf/044_3_0479.pdf.

Höhle, M., Happy pbirthday class of 2016, http://staff.math.su.se/hoehle/blog/2017/02/13/bday.html.

Höhle, M., US Babyname Collisions 1880-2014, http://staff.math.su.se/hoehle/blog/2017/03/01/morebabynames.html.

Examples

pbirthday(n=26, classes=365, coincident=2)
pbirthday_up(n=26L, prob=rep(1/365,365), method="R")$prob
pbirthday_up(n=26L, prob=rep(1/365,365), method="Rcpp")$prob