op_dist_outcome()
Abstract
Generates a floating-point numeric outcome that has the specified distribution, using the Simulation Kernel’s built-in random number generator.
Syntax
op_dist_outcome (dist_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().] |
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
Excerpt from: process model (frms_traf_gen); function block; function frms_traf_gen_schedule().
/* Determine the time at which to schedule the interrupt. */
next_pk_arrvl_time = op_sim_time () + op_dist_outcome (int_arrival_distptr);
/* Check to verify that this time is within the end time */
/* specification for this module. */
if ((next_pk_arrvl_time < gen_end_time) || (gen_end_time == FRMSC_APPL_END_OF_SIM))
{
/* Schedule the self-interrupt. */
op_intrpt_schedule_self (next_pk_arrvl_time, FRMSC_FR_APPL_TRAF_GEN);
}
Details
The specified distribution can be either a predefined algorithmic distribution, or a numeric tabular distribution that has previously been loaded using the KP op_dist_load(). This KP performs a table lookup for tabular distributions, and performs numeric computations for algorithmic distributions (such as exponential).
The random number stream used by this KP is generated by calls to the BSD random() procedure, and is shared by all Dist package KPs and by the generator modules. The random number stream is dependent on an initial seed, which can be altered via the simulation preference “seed” (see Chapter 1 “Executing a Discrete Event Simulation” on page 1 for more information). Simulation results are repeatable if the simulation inputs are identical, including the same random seed.
Note: A preference lets you specify whether random number streams apply simulation-wide or per-module. See “per_module_random_stream“ on page 208 for details.
Purpose
Provides a mechanism to obtain a stochastic value that conforms to a probability distribution. The most common application of this capability is to compute stochastic interarrival times that occur between packets generated in a processor. However, any simulation parameter that should be stochastically distributed can be derived from the distribution facility.
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)
- Recoverable Error: Distribution pointer is NIL.
Reference
- Use the KP op_dist_load() to load a distribution for use by this KP
- Use the KP op_dist_uniform() to obtain a uniformly distributed random value
- Use the KP op_dist_outcome_ext() to obtain distributions using a user-specified random number value
- Use the KP op_dist_outcome_gen() to obtain distributions using a user-supplied random number generator (these distributions are independent of the Simulation Kernel’s random number generator)
- Use the KPs op_intrpt_schedule_self(), op_intrpt_schedule_remote(), or op_intrpt_schedule_call() to respectively schedule self interrupts, remote interrupts, or procedure interrupts