IV' Random Numbers - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

IV' Random Numbers

Description:

CS452/Mgt532 Simulation for Managerial Decisions. The Robert O. Anderson ... retrospectively consists of equally likely single digits not random since the ... – PowerPoint PPT presentation

Number of Views:65
Avg rating:3.0/5.0
Slides: 13
Provided by: mpeter2
Category:

less

Transcript and Presenter's Notes

Title: IV' Random Numbers


1
IV. Random Numbers
  • M. Peter Jurkat
  • CS452/Mgt532 Simulation for Managerial Decisions
  • The Robert O. Anderson Schools of Management
  • University of New Mexico

2
Need for Random Numbers
  • To generate values from a statistical
    distribution
  • Examples a time interval after the previous
    arrival (e.g., neg exp), a value of a service
    time (e.g., uniform), a number of items in an
    order (e.g., Poisson)
  • Generation of random numbers satisfied this need
  • Informally, random numbers are selections from a
    statistical distribution

3
Sources of Random Numbers
  • Physical processes
  • Noise in electrical signal generators, background
    electron scatter (atmospheric, CRT)
  • Advantages natural, occurs in systems that use
    random numbers
  • Disadvantage hard to measure and make into
    useful sequences, cannot specify distribution
  •  Existing tables
  • Last digits of phone number, log, sine, etc.
    tables
  • Advantages already exist, many in digital form
  • Disadvantages not really random, hard to use in
    simulations, cannot specify distribution

4
Sources of Random Numbers
  •  Digital algorithms
  • Last digits of arithmetic procedure
  • Advantages can specify distribution, easy to use
    in computer simulation
  • Disadvantages not really random (algorithm gt
    deterministic, will repeat sequence (cycles)
  • Preferred method for computer based simulations
    long history, well developed
  • Good algorithms have long periods and pass random
    tests widely used known as pseudo-random
    number generators

5
Definition
  • Formally, common phrases "at random", "with equal
    chance", "equally likely" usually mean uniformly
    distributed
  • The sequence 12345678901234567890,
    retrospectively consists of equally likely single
    digits not random since the next digit can be
    predicted from the previous successive digits
    depend on previous one gt not independent
  • Therefore, random numbers are defined to be
    independent samples from a Uniform distribution
  • Either real numbers on 0,1 or integers on 0,

6
Characteristics
  • How do we know a sequence of numbers are
    uniformly distributed? satisfy tests that
    sequences known to be uniform satisfy
  • Need statistical hypothesis testing
  • In sequence of integers single digits, pairs,
    triplets, etc., have to be equally likely why?
  • hard and laborious to check (e.g., for triplets
    would have to generate at least 1000 digits
    actually at least 5000 for Chi-squared test
    many more for longer subsequences) ultimately
    impractical

7
Narrow Definition
  • Random integers can be generated from uniformly
    distributed random real numbers on 0,1
  • Using Excel to generate integers uniformly
    distributed
  • from 1 to N use trunc(rand()N1,0)
  • from K to M use trunc(rand()(M1-K) K,0)
  • Therefore, redefine random numbers to be
    independent real samples from 0,1

8
Linear Congruential Generator (LCG) for Uniform
Random Digits
  • Preferred method begin with a seed, x0, and
    successively generate the next pseudo-random
    number by xi1 (axi c) mod m, for i
    0,1,2, where
  • m is the largest prime less than largest integer
    computer can store
  • a relatively prime to m
  • c is arbitrary, often 0
  • Let A be largest integer less than A, then N
    mod m N N/TT
  • Accept LCG with m, a, and c which passes tests
    which are also passed by know uniform digits

9
Testing Random Numbers
  • Most common are tests of distribution (in each
    case compare to expected by Chi-Square test - see
    Banks Section 7.4)
  • Frequency tests Chi-Squared and
    Kolmogorow-Smirnov (count numbers in bins)
  • Autocorrelation test compare autocorrelation at
    lags of 1, 2,
  • Run test replace each number by 0 if lt.5 and 1
    is gt .5, count number of runs
  • Gap test convert to integers, count number of
    intervening digits before same digit again
  • Poker test convert to integers, take 5 digits,
    make poker hand out of it

10
Hypothesis Testing for Distributions
  • H0 Sequence is uniformly distributed
  • Test statistic c2 (pronounced chi-squared)
    applied to bins (single digits, pairs,
    triplets,etc.)
  • p-value probability test statistic is as far
    from expected as it is also probability that of
    making a mistake by rejecting H0 if small
    (e.g., p lt .05), reject
  • See spreadsheet RandomNum.xls

11
Empirical Random Variates
  • When desired distribution does not have a know
    mathematical form and data is available, can
    generate variates from it
  • Use inverse function technique
  • Make table of values in increasing order with
    their associated cumulative probability
  • Generate a random number (from uniform on 0,1
    interval) interpret this as a cumulative
    probability
  • Find associated value
  • Excel procedure vlookup() used previously

12
Non-Uniform Variate Generation
  • Inverse function technique can be used to
    generate numbers from any statistical
    distribution calculate values from the
    distribution and use them as empirical values
    Banks Section 8.1
  • Special techniques for particular distributions
    in rest of Banks Chapter 8
Write a Comment
User Comments (0)
About PowerShow.com