## Simulate the time-to-failures given θ (posterior samples) under load profile

### Description

Give the estimated probability of failure after 30 years (or can be set via `set_returnPeriod`) based on a large number of replications with given load profile. The θ's, where

θ = (μ_a, σ_a, μ_b, σ_b, μ_c, σ_c, μ_n, σ_n, μ_σ0, σ_σ0),

will then be used to solve the Canadian ADM for time-to-failure T_f and probability of failure P_f with and without duration of load (DOL) effect.

### Usage

```solveCanADM(inputTheta, inputPhi, verbose = FALSE)
```

### Arguments

 `inputTheta` a matrix where each row is θ `inputPhi` performance factor φ of the load `verbose` displays the index, the number of failure of the current θ, and the number of failure of the current θ with no DOL effect to console if TRUE

### Details

The equation of the Canadian model is:

d/dt α(t) = [(a * τ_s) * (τ(t) / τ_s - σ_0)_+]^b + [(c * τ_s) * (τ(t) / τ_s - σ_0)_+]^n * α(t),

where

* (a, b, c, n, η) are piece-specific random effects, and

- a|μ_a, σ_a ~ Log-Normal(μ_a, σ_a);

- b|μ_b, σ_b ~ Log-Normal(μ_b, σ_b);

- c|μ_c, σ_c ~ Log-Normal(μ_c, σ_c);

- n|μ_n, σ_n ~ Log-Normal(μ_n, σ_n);

- η|μ_σ0, σ_σ0 ~ Log-Normal(μ_σ0, σ_σ0) and set σ_0 = η / (1 + η).

* (x)_+ = max(x, 0).

* σ_0 serves as the stress ratio threshold in that damage starts to accumulate only when τ(t)/τ_s > σ_0.

* The performance factor φ comes from the load τ(t) = φ*R_o*(γ*D_d+D_s(t)+D_e(t)) / (γ*α_d+α_l).

* The default time step when solving the Canadian model numerically is 100 hours. It can be set via `set_timeStep`.

* The probability is calculated as (number of failed samples / total number of simulation samples). Total number of simulation samples can be set via `set_simuSampleSize`.

### Value

Returns a list of three elements. The first element of the list is the time-to-failure T_f. The second element is the probability of failture P_f. The third element is the probability of failure P_f without DOL effect. The index of θ, the number of failure of the current θ, and the number of failure of the current θ with no DOL effect will be printed in this order along the way if `verbose` is TRUE.

### References

Yang, C. H., Zidek, J. V., & Wong, S. W. (2019). Bayesian analysis of accumulated damage models in lumber reliability. Technometrics, 61(2), 233-245.

Wong, S. W., & Zidek, J. V. (2018). Dimensional and statistical foundations for accumulated damage models. Wood science and technology, 52(1), 45-65.

### Examples

```# This is a small demo with 50 simulated failure times
set_simuSampleSize(50)
# simulate the time-to-failures given theta under the residential loads