rHDR: Hubbard Decision Research Pseudo-Random Number Generator

Description Usage Arguments Details Value References Examples

View source: R/hdr.R

Description

Hubbard Decision Research (HDR) Pseudo-Random Number Generator (PRNG)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
rHDR(
  x,
  t1 = c(2499997, 1800451, 2000371, 1796777, 2299603),
  a1 = 7450589,
  b1 = 4658,
  c1 = 7450581,
  d1 = 383,
  e1 = 99991,
  f1 = 7440893,
  t2 = c(2246527, 2399993, 2100869, 1918303, 1624729),
  a2 = 7450987,
  b2 = 7580,
  c2 = 7560584,
  d2 = 17669,
  e2 = 7440893,
  f2 = 1343
)

Arguments

x

a vector (or a 'n * m' matrix) of seeds, where 'm“ corresponds to dimensions of random numbers. Default 'm<=5'. See **HDR Dimensions** section below.

t1, t2

T constants (prime numbers) for 1st and 2nd term, respectively. The length of these vectors determine maximum number of dimensions for HDR PRNG. Default values are t1=c(2499997, 1800451, 2000371, 1796777, 2299603) and t2=c(2246527, 2399993, 2100869, 1918303, 1624729)

a1, a2

A constants. Default values are a1=7450589, a2=7450987

b1, b2

B constants. Default values are b1=4658, b2=7580

c1, c2

C constants. Default values are c1=7450581, c2=7560584

d1, d2

D constants. Default values are d1=383, d2=17669

e1, e2

E constants. Default values are e1=99991, e2=7440893

f1, f2

F constants. Default values are f1=7440893, f2=1343

Details

HDR PRNG is given by the formula:

R(X)=mod(mod(mod(1015-11,mod(X x T1,A1)*B1+C1)*D1,E1)*F1+ mod(mod(1015-11, mod(X x T2,A2)*B2+C2)*D2,E2)*F2,232)

Further details on each of the dimensions

| Term | Dimension | Description | | —- | ——— | ———– | | 1 | Trial ID | This represents a unique identifier for a given scenario in a simulation. This 8 decimal digit identifier allows for up to 100 million unique trials for each variable in a model| | 2 | Variable ID | This is a unique identifier for a variable. It would be an 8-digit variable ID allowing for up to 100 million unique variables. For example, if “Monthly Demand for Product X” and “average time spent in activity Y” were variables in a model, they would each be given unique variable IDs. Organizations may structure their Variables IDs so that related variables are in groups. For example, perhaps all marketing and sales related variables have “11” for the first two digits and all cybersecurity related variables have “73” for the first two digits, and so on. Variable IDs could be assigned on an ad hoc basis but a large organization making many models with a lot of shared variables would want to develop an internal library of assigned variable IDs similar to an accountant’s “chart of accounts.”| | 3 | Entity ID | This identifies an organization or some other category of users. A corporation or government agency may be assigned a unique 8 decimal digit Entity ID. Since this provides for 100 million potential entities, that should be enough for every business, not for profit and government agency that wants one on the planet. This is useful if there are models using random variables from many organizations do not have variables that produce the same random sequences. For example, many banks may use variables defined by the FDIC for “stress testing” to ensure banks are financially stable even during times of economic stress. The bank would want to ensure that internally defined variables with the same Variable ID are not correlated to the shared variables. The FDIC would supply the variable ID along with the Entity ID of the FDIC so that every bank using those variables produces the same sequence while avoiding duplicating the sequence of internally defined variables. A default Entity ID of 0 can be used by anyone as long as sharing variables would not be an issue.| | 4 | Time ID | This identifies a particular time unit for a given variable/trial/entity combination. This allows one scenario for a given variable to contain an entire unique time series. A 7-digit time series ID would allow for time series containing 115 days of seconds, 19 years of minutes, or 27,397 years of days. This is an optional dimension. Variables that do not represent a time series use the default Time ID of 0.| | 5 | Agent ID | This provides a fifth optional dimension for the counter-based PRNG. One possible use is as an identify for agents in agent-based modeling. If this ID is not used, the default value is 0.|

Value

vector or pseudo-random numbers related for every one of (combination of) seeds.

References

D. W. Hubbard, "A Multi-Dimensional, Counter-Based Pseudo Random Number Generator as a Standard for Monte Carlo Simulations," 2019 Winter Simulation Conference (WSC), National Harbor, MD, USA, 2019, pp. 3064-3073. DOI: 10.1109/WSC40007.2019.9004773

Examples

1
2
rHDR(c(1:10))
rHDR(matrix(c(1:10), byrow=TRUE, nrow=5))

isaacfab/rmetalog documentation built on Jan. 31, 2021, 10:29 p.m.