# Appendix A: Generating Random Numbers from a Distribution

 Appendix A Generating Random Numbers from a Distribution

## Contents

More Resources:
BlockSim Examples Collection

Simulation involves generating random numbers that belong to a specific distribution. We will illustrate this methodology using the Weibull distribution.

# Generating Random Times from a Weibull Distribution

The cdf of the 2-parameter Weibull distribution is given by:

$F(T)=1-{{e}^{-{{\left( \tfrac{T}{\eta } \right)}^{\beta }}}}\,\!$

The Weibull reliability function is given by:

\begin{align} R(T)= & 1-F(t) \\ = & {{e}^{-{{\left( \tfrac{T}{\eta } \right)}^{\beta }}}} \end{align}\,\!

To generate a random time from a Weibull distribution, with a given $\eta \,\!$ and $\beta \,\!$, a uniform random number from 0 to 1, ${{U}_{R}}[0,1]\,\!$ , is first obtained. The random time from a weibull distribution is then obtained from:

${{T}_{R}}=\eta \cdot {{\left\{ -\ln \left[ {{U}_{R}}[0,1] \right] \right\}}^{\tfrac{1}{\beta }}}\,\!$

## Conditional

The Weibull conditional reliability function is given by:

$R(t|T)=\frac{R(T+t)}{R(T)}=\frac{{{e}^{-{{\left( \tfrac{T+t}{\eta } \right)}^{\beta }}}}}{{{e}^{-{{\left( \tfrac{T}{\eta } \right)}^{\beta }}}}}\,\!$

The random time would be the solution for $t\,\!$ for $R(t|T)={{U}_{R}}[0,1]\,\!$.

# BlockSim's Random Number Generator (RNG)

Internally, ReliaSoft's BlockSim uses an algorithm based on L'Ecuyer's [RefX] random number generator with a post Bays-Durham shuffle. The RNG's period is approximately 10^18. The RNG passes all currently known statistical tests, within the limits the machine's precision, and for a number of calls (simulation runs) less than the period. If no seed is provided the algorithm uses the machines clock to initialize the RNG.