doc/chyper.R

## ---- include = FALSE---------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(chyper)

## -----------------------------------------------------------------------------
dchyper(1, 50, c(300, 500), c(56, 14))

## -----------------------------------------------------------------------------
set.seed(1)
draws <- rchyper(10000, 50, c(300, 500), c(56, 14))
hist(draws, breaks = seq(0,5,1) - 0.5)
print(sum(draws==1)/length(draws))

## -----------------------------------------------------------------------------
pchyper(1, 50, c(300, 500), c(56, 14))

## -----------------------------------------------------------------------------
print(sum(draws<=1)/length(draws))

## -----------------------------------------------------------------------------
print(sort(draws)[length(draws)/2])
qchyper(0.5, 50, c(300, 500), c(56, 14))

## -----------------------------------------------------------------------------
pvalchyper(1, 50, c(300, 500), c(56, 14), "upper")

## -----------------------------------------------------------------------------
mleS(draws, c(300, 500), c(56, 14))

## -----------------------------------------------------------------------------
set.seed(1)
draws <- rchyper(10^6, 50, c(300, 500), c(56, 14))
mleS(draws, c(300, 500), c(56, 14))

## -----------------------------------------------------------------------------
mleM(1, draws, 50, c(300, 500), c(0, 14))

## -----------------------------------------------------------------------------
mleN(1, draws, 50, c(0, 500), c(56, 14))
WillNickols/chyper documentation built on Sept. 1, 2024, 10:11 p.m.