twonodeSim {BayesMassBal} | R Documentation |
Two Node Process Data Simulation
Description
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")
.
Usage
twonodeSim(
K = 7,
feed = list(rate = 100, sd = 6, CuFeS2grade = 1.2),
rec = list(CuFeS2 = list(mean = c(98, 95)/100, var = c(5e-05, 8e-05)), gangue =
list(mean = c(7, 4)/100, var = c(5e-05, 2.5e-05))),
assayNoise = list(CuFeS2 = c(0.15, 0.2, 0.05, 5e-05, 0.005), gangue = c(5, 1, 0.03,
2, 0.5)),
truncation = TRUE
)
Arguments
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. |
Details
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 \sigma^2 \leq \mu(1-\mu)
, 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 non-negative. 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 Monte-Carlo 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.
Value
Returns a list of simulated data and expected values. List members are as follows:
simulation |
List of matrices giving simulated data. |
expectations |
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. |
Examples
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))