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

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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