Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 351/ IT 351 Modelling and Simulation Technologies Random Variates Dr. Jim Holten.

Similar presentations


Presentation on theme: "CS 351/ IT 351 Modelling and Simulation Technologies Random Variates Dr. Jim Holten."— Presentation transcript:

1 CS 351/ IT 351 Modelling and Simulation Technologies Random Variates Dr. Jim Holten

2 Random Distributions Basic Statistics Common Random Distributions Generating Custom Distributions Generating Random Variates (from custom distributions) CS 351/ IT 351

3 Using Random Variates x’ = x + v –Add random “noise” to the variable’s value –Called additive noise –Commonly used x’’ = x* v –Multiply random “noise” times variable’s value –Called multiplicative noise –Not as common Generating Custom Distributions Generating Random Variates (from custom distributions) CS 351/ IT 351

4 Basic Statistics min, max, count, sum (sum of squares aka sumsq can be useful too) range = max – min mean = Σ x i / count variance = Σ (x i – mean) 2 / count standard deviation -- σ = sqrt(variance)

5 CS 351/ IT 351 Other Basic Statistics mode –The center value when all samples are in order by value kurtosis (aka skew) κ = Σ(x[i] – mean) 3, i [0, n] histogram – a bar chart of frequency of value occurrences (usually counts of values within evenly spaced intervals).

6 CS 351/ IT 351 Histogram of a Set of Values Find the min, max, and range of the values Divide the range into k value intervals (i = 0, k - 1) (aka “buckets”), I i =[v i, v i+1 ]. Count the number of values in each interval h i = count for interval i v i ≤ v < v i+1 → h i = h i + 1 Generally displayed as a bar chart. The histogram bar chart defines a “shape” of value occurrence counts.

7 CS 351/ IT 351 Common Random Distributions The Probability Distribution Function (PDF) shape (aka Probability Density Function) defines a distribution which matches the shape of its histogram. Common standard distributions: Uniform, Normal, Exponential, Poisson It can define other distribution shapes as needed. Integrate the PDF (from -∞ to X for each value of X) to get the Cumulative Distribution Function (CDF)

8 CS 351/ IT 351 PDF from a Histogram Start with the histogram. Normalize the k counts to measured probabilities for each value interval’s counts: n = Σh j p i = h i / n, for j [0, n-1] This defines a probability distribution function (PDF), aka probability density function for the variable's values. It’s shape can be compared to the common distributions for approximate matching.

9 CS 351/ IT 351 CDF from the PDF Create the piecewise linear PDF from the histogram counts. Create a CDF via c j = Σp i, for all i ≤ j for each of the k bucket value intervals. This gives a piecewise linear CDF over the range of values for the original data.

10 CS 351/ IT 351 Random Variates Generation Project (map) the random variates obtained from Uniform[0, 1.0) (the CDF vertical axis) to the original data values (the horizontal axis) via the CDF curve. Use linear interpolation for “better” intermediate values.

11 CS 351/ IT 351 Random Variates Math packages include a random number generator. It must be “seeded” once, then it will generate a different random number each time it is called. If the same seed is used then the same sequence of “random” values will be retrieved.

12 CS 351/ IT 351 Random Variates (via Java) Random rand = new Random(long_seed_value) –seed the random number generator. –Do this ONCE for the entire random sequence. value = rand.nextDouble() –retrieve one new random value – in the range [0.0, 1.0). value = rand.nextGaussian() –retrieve one new random value –from Normal distribution, mean = 0.0, std_dev = 1.0

13 CS 351/ IT 351 Seeding Random Variates The same seed generates the same sequence of random variates for a given generator. Often the current epoch time in seconds or milliseconds is used to get a “random seed” so each run uses a different sequence of random variates. Using the seed again starts the sequence over.

14 CS 351/ IT 351 Getting A Near Random Seed (Java) Get the seed –import java.util.Date; –Date date = new Date(); –long ms_since_epoch = date.getTime(); Seed the generator –Random rand = new Random(ms_since_epoch); The actual sequence generated is now (somewhat) independent for each run because the time changes.


Download ppt "CS 351/ IT 351 Modelling and Simulation Technologies Random Variates Dr. Jim Holten."

Similar presentations


Ads by Google