twonodeSim  R Documentation 
Simulates data for a stochastic two node, two component process at steady state. Location indices are the same as what is shown in vignette("Two_Node_Process", package = "BayesMassBal")
.
twonodeSim( K = 7, feed = list(rate = 100, sd = 6, CuFeS2grade = 1.2), rec = list(CuFeS2 = list(mean = c(98, 95)/100, var = c(5e05, 8e05)), gangue = list(mean = c(7, 4)/100, var = c(5e05, 2.5e05))), assayNoise = list(CuFeS2 = c(0.15, 0.2, 0.05, 5e05, 0.005), gangue = c(5, 1, 0.03, 2, 0.5)), truncation = TRUE )
K 
Numeric specifying the number of sample sets to be simulated. 
feed 
List specifying qualities for the process grade. See default for required structure. 
rec 
List specifying mean and variance in process performance. See default for required structure. 
assayNoise 
List specifying standard deviations of random noise added to simulated process outputs. See default for required structure. The index of a vector within the list is equivalent to the index of the sampling location. See Details section for important information on specifying these values. 
truncation 
Logical indicating if the simulation should be rerun, and previous results discarded, until no observed values are less than 0. Default is TRUE. See details for more information. 
Each of the K
data sets collected from the twonodeSim()
simulation is independent and identically distributed.
The feed rate to the process is normally distributed with a mean of feed$rate
, and a standard deviation of feed$sd
. If the feed rate is sufficiently small, and the standard deviation is sufficiently large, negative feed rates can be generated.
Process recovery at each node is simulated from a beta distribution, reparameterized as shown in this post to make parameter specification more intuitive. This reparameterization is only valid when σ^2 ≤q μ(1μ), and the list argument rec
must be specified as such.
The steps of the simulation for each sample set are:
Draw a random normally distributed feed rate.
Draw random values for recovery of the two components at each node.
Calculate mass flow rate at each location. These mass flow rates are the true mass flow rates, given the process variability.
Adds normally distributed noise to each observation as specified in argument assayNoise
If the standard deviations supplied to feed
and assayNoise
are sufficiently large, the simulation can return negative mass flow rates.
The argument truncation = TRUE
discards negative mass flow rates, and reruns the simulation until all values are nonnegative. For some combinations of a large K
and specifications in feed
and assayNoise
, this can happen frequently. If if the simulation is run three or more times a warning will be printed that the returned expectations are unreliable. If this is the case, expectations should be calculated using analytical or MonteCarlo methods outside of the abilities of this function. For the default parameters, truncation can occur, but is rare. The default parameters were chosen in a way that makes a truncation warning highly unlikely.
Returns a list of simulated data and expected values. List members are as follows:

List of matrices giving simulated data. 

List of matrices giving expected values of the mass flow rate for each component at every location. See the Details section for information about instances that may create reliability issues with this output. 
y < twonodeSim()$simulation ## Then the BMB function can be run as C < matrix(c(1,1,0,1,0,0,1,1,0,1), byrow = TRUE, ncol = 5, nrow = 2) X < constrainProcess(C = C) BMB(X = X, y = y, BTE = c(100,600,1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.