day13 - COP 3503 Computer Science II CLASS NOTES - DAY #13...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
COP 3503 – Computer Science II CLASS NOTES - DAY #13 Randomization Random numbers are an important part of the modern world of computing. Cryptography, simulation, and system testing all rely on random number generation. This chapter deals with the generation and use of random numbers. Important Uses of Random Numbers 1. program testing - suppose we want to test a sorting algorithm by running 5000 iterations of the program on input arrays of 1000, 10000, and 100000 elements – to do this we need to generate random data sets. Once we have generated the test data and run the sort algorithm how do we know it works properly? One way is to test if the numbers in the array are arranged in increasing order (this requires a linear time algorithm to do this verification) – but how do we know that the numbers in the final sorted array are the same numbers that were in the original unsorted array? How this can be accomplished in the explained in the next bullet. random permutations – a random permutation of the first N integers is a sequence of N integers that contains each of 1, 2, …, N exactly once. This can be fast technique for determining if a sort algorithm works, since regardless of the permutation chosen as the input sequence the sorted output sequence will always be 1, 2, …, N. efficiency comparison – useful for running algorithms repeatedly for determining running times. simulations – generates random events. Example, in testing operating systems, determining the average waiting time of a process can be determined by simulation of random arrival of processes to the system. randomized algorithms – a random number is used to determine which step in the algorithm will be performed next. This is common when the algorithm involves (at any step) a selection amongst several alternatives that are more or less indistinguishable. For example, most commercial chess games have the system’s first move made at random rather than deterministically (always the same first move). Day 13 - 1 CHAPTER 9
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Random Numbers and Pseudo-random Numbers You probably already have some idea of what mean when we say that a number is random. The question of exactly what should be the criteria for a sequence of numbers to be random, is a very difficult one to answer. we might say, for example, that a random sequence of 0s and 1s, would be a sequence generated by repeatedly tossing a fair coin and recording a 0 for each head and a 1 for each tail. The problem with this definition is that it implies the sequence 00000000… is random, and further, that it is no more likely or less likely than any other sequence of 0s and 1s. It is probably more useful at this point to consider a sequence as random if knowing the first n terms of the sequence, we are not able to predict (with 100% accuracy) the (n+1)st term. This
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/22/2009 for the course COP 3503c taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 12

day13 - COP 3503 Computer Science II CLASS NOTES - DAY #13...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online