R/sim_single_stages.R
sim_single_stages.Rd
This function gives a simulated number of CFUs after each stage of the mixing process.
sim_single_stages( mu, sigma, alpha_in, k,l, r, distribution,n_sim)
the average number of CFUs (\(\mu\)) in the mixed sample, which is in a logarithmic scale if we use a Lognormal / Poisson lognormal distribution
the standard deviation of the colony-forming units in the mixed sample on the logarithmic scale (default value 0.8)
concentration parameter at the initial stage
number of small portions / primary samples
number of revolutions / stages
the rate of the concentration parameter changes at each mixing stage
what suitable distribution type we have employed for simulation such as "Poisson-Type A"
or "Poisson-Type B"
or "Lognormal-Type A"
or "Lognormal-Type B"
or "Poisson lognormal-Type A"
or "Poisson lognormal-Type B"
number of simulations
average number of colony forming units in the single mixing plan with \(l\) number of stages.
Let \(N'\) be the number of colony-forming units in the mixed sample which is produced by contribution of \(k\) primary samples mixing, \(N' = \sum N_i\) and \(l\) be the number of stages in the mixing process. This function provides simulated number of CFUs after each stages of the mixing process. To more details, please refer the details section of compare_mixing_3.
Nauta, M.J., 2005. Microbiological risk assessment models for partitioning and mixing during food handling. International Journal of Food Microbiology 100, 311-322.
mu <- 100
sigma <- 0.8
alpha_in <- 0.01
k <- 30
l <- 25000
r <- 0.01
distribution <- "Poisson lognormal-Type B"
n_sim <- 2000
stages <-c(1:l)
Prob_df <-
data.frame(stages,sim_single_stages(mu,sigma,alpha_in,k,l,r,distribution,n_sim))
colnames(Prob_df) <- c("no.revolutions","CFU")
plot_sim_single_stages <- ggplot2::ggplot(Prob_df,ggplot2::aes(x = no.revolutions, y = CFU)) +
ggplot2::geom_line() +
tidyquant::geom_ma(ma_fun = SMA, n = 50, linetype = 1, colour = "red") +
ggplot2::xlab(expression("Number of revolutions")) +
ggplot2::ylab(expression("Expected total number of CFUs")) +
ggplot2::theme_classic() +
ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5)) +
ggthemes::scale_colour_colorblind()
print(plot_sim_single_stages)