op_dist_outcome_ext()

Abstract

Generates a floating-point numeric outcome that has the specified distribution, using a user-specified random number value.

Syntax

op_dist_outcome_ext (dist_ptr, rndm_num)
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().]
rndm_num double A uniformly distributed random number between zero (inclusive) and one (exclusive) that will be used to obtain a random outcome that conforms to the distribution specified by the dist_ptr argument. (See the note in 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

/* Obtain the specified value for the mean calls per slot of the traffic source. */
op_ima_obj_attr_get (op_id_self (), "mean_calls_per_slot", &mean_calls_per_slot);

/* Load in the poisson distribution for number of new calls per slot. */
callgen_dist_ptr = op_dist_load ("poisson", mean_calls_per_slot, 0.0);

/* Set up the seed for BSD’s random number generator. */
/* Use the seed specified via this module’s attribute. */
op_ima_obj_attr_get (op_id_self(), "callgen_seed", &callgen_seed);
initstate (callgen_seed, (char*) &callgen_rand_state, 8);
setstate (callgen_rand_state);
rand_val = (unsigned int) random ();

/* Normalize to the zero-one interval */
uniform_rand_val = (double) rand_val / ((double) 0x7FFFFFFF + 1.0);

/* Since this is the first slot, obtain the number of calls to initiate. */
num_new_calls = op_dist_outcome_ext (callgen_dist_ptr, uniform_rand_val);
for (num_new_calls; num_new_calls > 0; num_new_calls--)
	op_pk_send (op_pk_create_fmt ("atm_cell"), PHYS_PORT);

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

This KP is provided as an alternative to op_dist_outcome(), which relies on random numbers generated by the BSD random number generator random() and which also shares its random number stream for all standard consumers of random numbers in the simulation (e.g., generators, bit-error calculations, etc.). All random variable outcomes (for both KPs) are performed by first obtaining a uniformly distributed random number and using this value to invert the cumulative distribution function of the specified distribution. By allowing the specification of the uniform random number, this KP makes it possible to integrate an arbitrary number of independent random number streams, obtained from random number generators of the user’s choice, into a simulation.

The Example section for this KP shows process model code that makes use of state variables to create an independent state for each instance of a traffic generator. The state memory is used to individually seed and maintain random number streams via the BSD random number generator random(), which can have extremely large periods when configured with sufficient state. An easier way of creating an independent random number stream is to use op_prg_random_gen_create() and op_prg_random_double_gen().

Note: In most cases, op_dist_outcome_ext() will not perturb the Simulation Kernel’s random number stream. This does not apply, however, if dist_ptr* references any of the following distributions: Binomial, Erlang, Extreme, Laplace, Lognormal, Normal, Pareto, Rayleigh and Weibull. To be completely independent of the Simulation Kernel’s random number stream, use op_dist_outcome_gen().

If you want to use the Normal distribution, you can guarantee reproducible results from op_dist_outcome() (i.e., results unaffected by calls to op_dist_outcome_ext()) by using the Fast Normal instead of the Normal distribution. Keep in mind that this workaround will produce a “coarser” approximation of the Normal distribution; see Figure 29 Normal and Fast Normal PDF Definition for more information.

Purpose

This KP provides an alternative for users who desire to bypass the default random number generation relied upon by the KP op_dist_load(). Reasons for doing this may have to do with a need to separate the random number sources used for different purposes, or a need to use a random number generator with different properties.

A large number of repeated calls to this KP will generate a set of values that conform to the specified distribution. In most cases, this KP allows the Simulation Kernel’s internal random number generator to be bypassed; exceptions are described in the Details section.

Errors

  • Program Abort: Segmentation violation. (due to an invalid distribution pointer)
  • Recoverable Error: Distribution pointer is NIL.
  • Recoverable Error: Random number (<rndm_num>) is out-of-range. (if the passed value is not >= 0 and <1)

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_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 KP op_dist_uniform() to obtain uniformly distributed random numbers

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com