powerForQual = function(SampSize, ThemePrevalence, NumInstances) {
  pnbinom(SampSize-NumInstances, size = NumInstances, prob = ThemePrevalence)
}

sampSizeForQual = function(Power, ThemePrevalence, NumInstances) {
  qnbinom(Power, size = NumInstances, prob = ThemePrevalence) + NumInstances
}

powerForQual(30, 0.1, 2)

sampSizeForQual(0.8, 0.1, 2)
