op_dist_outcome_gen()
Abstract
Generates a floating-point numeric outcome that has the specified distribution, using a user-specified random number generator completely independent of the Simulation Kernel’s random number generator.
Syntax
op_dist_outcome_gen (dist_ptr, gen_ptr)
| Argument | Type | Description |
|---|---|---|
dist_ptr |
Distribution * |
pointer to a loaded distribution [A pointer to a distribution can only be obtained from the KP op_dist_load().] |
gen_ptr |
PrgT_Random_Gen * |
user-defined random number generator (see Details) |
Return Type
double
An outcome of a random variable that has the specified distribution. If a recoverable error occurs, the constant OPC_DBL_INVALID will be returned.
Example
PrgT_Random_Gen * rand_gen_ptr;
Distribution * dist_ptr;
double next_rand;
/* Create a random number generator */
rand_gen_ptr = op_prg_random_gen_create (seed);
/* Load a distribution */
dist_ptr = op_dist_load ("normal", 10.0, 0.5);
/* Get a random number */
next_rand = op_dist_outcome_gen (dist_ptr, rand_gen_ptr);
Details
Before calling this function, the random number generator specified by gen_ptr must have been created using the op_prg_random KPs (see “Random Sub-Package“ on page 6).
Purpose
This KP provides a way to completely bypass the Simulation Kernel’s internal random number generator when generating random numbers. The KP op_dist_outcome_ext() also bypasses the internal random number generator, but not for all distributions. The Binomial, Erlang, Extreme, Laplace, Lognormal, Normal, Pareto, Rayleigh, and Weibull distributions need additional random numbers. This KP specifies a user-defined generator to supply the initial random number and any additional random numbers that might be needed.
A large number of repeated calls to this KP will generate a set of values that conform to the specified distribution.
Errors
- Program Abort: Segmentation violation. (due to an invalid distribution pointer or an invalid random number generator pointer)
- Recoverable Error: Distribution pointer is NIL.
- Recoverable Error: PrgT_Random_Gen pointer is NIL.
Reference
- Use the KP op_dist_load() to create distributions
- Use the KP op_dist_outcome() to obtain distributions using the Kernel’s built-in random number generator
- Use the KP op_dist_outcome_ext() to obtain distributions using a user-specified random number value
- Use the KP op_dist_uniform() to obtain uniformly distributed random numbers