L5 - Computer Models Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Ideally, what should random values be?

A
  • Random – the values should appear to be in a random sequence
  • Evenly distributed – values should be evenly distributed over the range of possible values
  • Independent – if a value appears, then the chance of appearing again is unaffected
  • So, a good random number generator should be capable of producing a long series of independent, nonrepeating values that appear to be in a random order and produce values that are well distributed over the range 0 to just less than 1.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When can we sample from a discrete distribution?

A

Provided we can associate a likelihood or probability with each outcome, we can use random digits to produce a random sample representing the discrete distribution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you generate a sample from a descrete distribution?

A

Assuming that we have a table of outcomes and associated probabilities (expressed as percentages):
1. Add a column to the table containing cumulative percentage
2. Add a further column to the table entitled Random Numbers
3. In the row corresponding to the first outcome, begin with “0.0” and go up to just less than the cumulative percentage for that row (expressed as a decimal)
4. In subsequent rows, begin with the cumulative percentage (as a decimal) from the previous row
and again, go up to just less than the cumulative percentage for the current row (expressed as a
decimal) – so the final row will end with “<1.00”
5. Take a uniformly distributed computer generated random number and then choose the outcome
corresponding to where the random number is located in the Random Numbers column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can we generate a sample from a Continuous Uniform distribution?

A
  • A continuous uniform distribution represents cases where a variable is equally likely to be anywhere
    between a minimum and maximum value and is usually referred to as just a uniform distribution
    1. Take a uniformly distributed computer generated random number and use the following:
    𝑋 = min + (random number × (max − min))
  • If random number = 0.0, then X=min
  • If random number = 0.9999, then X=max (very nearly 1)
  • So, if equally likely to be anywhere between 10 and 30 minutes:
    𝑋 = 10 + (random number × (30 − 10))
  • Thus the random numbers 0.2277 and 0.8228 would correspond to 14.554 (10+0.2277×20) and 26.456
    (10+0.8228×20) minutes respectively.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can we generate a Sample from a Histogram?

A

If we are presented with data in the form of a histogram, then we can combine ideas from discrete distributions and uniform distributions to allow us to generate suitable random samples.

  • By using discrete to determine category (which bar) i.e. approximate min/max
  • Use uniform to model actual value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can we generate a Sample from a Normal Distribution?

A
  • Unlike other methods, there is no straightforward way of generating random samples for a Normal Distribution. We will look at Excel in more detail soon, but the Excel function =NORM.S.INV(random number) can be used to find a corresponding Z value (i.e. a normally distributed value with a mean of 0 and a standard deviation of 1).
  • We can then convert the Z value to the appropriate sampled value using:
    𝑋 = mean + standard deviation × Z
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can we generate a Sample from a Negative Exponential Distribution?

A
  • Luckily, the method for generating Z values for the negative exponential distribution is far more
    straightforward:
    𝑍 = − ln(1 − random number)

We can then use the following formula to produce a sampled value from a negative exponential
distribution with a given mean:
𝑋 = μZ

Where μ is the mean and X is the simulated value of interest

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you generate Random Numbers in Excel?

A

=RAND()
- Uniform random value between 0 < x < 1

= RANDBETWEEN(min, max)
- Random integer between min and max (inclusive)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you use excel for Discrete Distributions?

A
  • IF probability easier for a small number of categories
  • For example, if 5% of items are faulty
  • A1 contains formula =RAND()
    =IF(A1<0.05, “faulty”,“working”)
  • However can get messier with 3 or more categories
  • VLOOKUP less intuitive, but formulae easier for larger number of categories
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you use excel for Uniform Distribution?

A

Integers (whole numbers) very easy:
=RANDBETWEEN(min, max)

  • Continuous values use RAND():
  • E.g. to give continuous value between 10 and 30
  • Say Cell A1 contains =RAND()
    =10+(30-10)*A1
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you use excel for a Histogram?

A
  • Exactly as before, use two random numbers
  • First random number used to produce category and hence min and max
  • Discrete – either IF or VLOOKUP
  • Second random number used to determine position in the category - Continuous Uniform
  • Don’t use same random value for both parts
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you use excel for Normal Distribution?

A
  • Excel has built-in function to calculate Z values
    =NORM.S.INV(Random number)
    Can then multiply by sd and add mean to get X value
  • “Short-cut” to produce X value immediately
    =NORM.INV(Random number, mean, sd)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you use excel for Negative Exponential Distribution?

A

No built-in formula to find Z
However, fairlystraightforward to produce Z
=-LN(1-Random Number)

  • Multiply by mean to get the X value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly