Last chance! 50% off unlimited learning
Sale ends in
This function draws N random numbers from a distribution that approximates a median that is equal to the limit of detection (LOD, value x.LOD) but has an upper 95th percentile (x.u95) that is above x.LOD. We make the assumption that values above x.u95 are uniformly distributed between x.u95 and x.u95 + (x.u95 - x.LOD)
rmed0non0u95(n, x.u95, x.min = 0, x.LOD = 0.005)
A vector of N samples where the 50th and 97.5th quantiles approximate x.LOD and x.u95 respectively
Number of samples to draw
The upper limit on the 95th confidence/credible intervale (this is the 97.5 percentile)
The minimum allowed value (defaults to 0)
The limit of detection (defaults to 0.005)
John Wambaugh
breen2022simulatinghttk
Fup.95 <- 0.02
N <- 1000
set.seed(1235)
Fup.vec <- rmed0non0u95(n=N, x.u95=Fup.95)
quantile(Fup.vec,c(0.5,0.975))
quantile(rmed0non0u95(200,x.u95=0.05,x.min=10^-4,x.LOD=0.01),c(0.5,0.975))
hist(rmed0non0u95(1000,x.u95=0.05,x.min=10^-4,x.LOD=0.01))
quantile(rmed0non0u95(200,x.u95=0.005,x.min=10^-4,x.LOD=0.01),c(0.5,0.975))
hist(rmed0non0u95(1000,x.u95=0.005,x.min=10^-4,x.LOD=0.01))
Run the code above in your browser using DataLab