twonodeSim: Two Node Process Data Simulation

View source: R/twonodeSim.R

twonodeSimR 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. rate is the mean feed rate. sd is the standard deviation of the feed rate. CuFeS2grade is the mass percent CuFeS2 present in the feed. Grade is not stochastic. See Details for important information on specifying these values.

rec

List specifying mean and variance in process performance. See default for required structure. rec$component$mean is a vector giving mean fractional recovery of the given component for c(node1,node2). rec$component$var gives the variance in the process in a similar manner. See Details.

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 σ^2 ≤q μ(1-μ), and the list argument rec must be specified as such.

The steps of the simulation for each sample set are:

  1. Draw a random normally distributed feed rate.

  2. Draw random values for recovery of the two components at each node.

  3. Calculate mass flow rate at each location. These mass flow rates are the true mass flow rates, given the process variability.

  4. 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. twonodeSim()$simulation is structured so that it can directly be passed to the BMB function as the y argument.

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))

BayesMassBal documentation built on June 18, 2022, 1:08 a.m.