M6L2 Some Lousy Generators

.pdf

School

California Lutheran University *

*We aren’t endorsed by this school

Course

ISYE6644

Subject

Electrical Engineering

Date

Oct 30, 2023

Type

pdf

Pages

5

Uploaded by CountTapir3340

Random Devices These are physical devices that generate randomness . Examples include flipping a coin, atmospheric noise, mouse movements, quantum phenomena, or the floating material in lava lamps . The randomness properties of these devices are generally quite good. However, storing the sequence of random numbers generated by these devices can be challenging, making it difficult to reproduce experiments. Another limitation is the rate at which these devices can produce randomness; for example, flipping a coin is a slow process, and even automated devices can only generate random numbers at a certain rate. These methods often require the use of specialized equipment. Random Number Tables These are pre-generated tables of random numbers . An example is the book " A Million Random Digits with 100,000 Normal Deviates ". The main issue with this approach is that it is cumbersome and slow. The tables are also finite, so if you need more random numbers than the table provides, you are out of luck. Moreover, once a sequence of numbers has been tabulated, it is no longer random in the sense that anyone using the table can predict what the next number will be if they know where you are in the table. This is in contrast to an LCG, where the next number cannot be predicted without knowing the internal state of the generator. Mid-Square Method This method , proposed by John von Neumann , is to generate the next random number by taking the middle part of the square of the previous random number. While it's a creative idea, in practice this method performs poorly. The numbers it generates exhibit positive serial correlation, meaning that each number is not independent of the ones before it, contrary to the desired property of pseudorandom number generators. Moreover, the method can occasionally degenerate, producing a sequence of identical numbers. Mid-Square Method Example R Code The provided R code uses the Mid-Square Method to generate pseudorandom numbers, applies the Box-Muller transform to these numbers to obtain a normal distribution, and then creates a 2D scatter plot of these values. This plot is used to visually evaluate the quality of the Mid-Square Method as a pseudorandom number generator by looking for any noticeable patterns or biases in the distribution of points.
library(ggplot2) mid_square <- function (n, seed) { result <- numeric(n) x <- seed for (i in 1 :n) { x <- as.numeric(substr((x^ 2 ), start= 3 , stop= 8 )) result[i] <- x / 1e6 } return(result) } # Generate 10000 numbers and apply Box-Muller transform set.seed( 12345 ) u1 <- mid_square( 10000 , seed = 4321 ) u2 <- mid_square( 10000 , seed = 1111 ) z1 <- sqrt(- 2 * log(u1)) * cos( 2 * pi * u2) z2 <- sqrt(- 2 * log(u1)) * sin( 2 * pi * u2) df <- data.frame(z1, z2) ggplot(df, aes( x= z1, y= z2)) + geom_point( alpha= 0.1 , color = "blue" ) + geom_hline( yintercept = 0 , color = "black" ) + geom_vline( xintercept = 0 , color = "black" ) + coord_cartesian( xlim = c(- 4 , 4 ), ylim = c(- 4 , 4 )) + ggtitle( "Mid-Square Method" ) + labs( x= "Z1" , y= "Z2" ) + theme_minimal() + theme( plot.title = element_text( hjust = 0.5 ))
Mid-Square Method Example Python Code Python Notebook Fibonacci and Additive Congruential Generators These methods generate the next random number by adding together some previous numbers in the sequence. The main problem with these methods is that they tend to produce "runs" of small or large numbers. It's also not possible for three consecutive numbers to be in the order or . The reason for this is that each number is a sum of previous numbers, so if is small and is large, then must be large as well (since it includes in its sum), so it's impossible to have . Similarly, it's impossible to have for the same reason. In a truly random sequence, each of these orderings should occur with probability 1/3.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help

Browse Popular Homework Q&A

Q: Sharon Jones is single. During 2022, she had gross income of $159,800, deductions for AGI of $5,500,…
Q: What is the required external financing over the next year?
Q: Which species below has eight valence electrons in its Lewis symbol? F* S²- O Si Mg+ O Art
Q: The Lewis symbol for the silicon atom shows valence shell electrons. The number of covalent bonds…
Q: Are there any negative allosteric regulators for glycogen phosphorylase?
Q: The mass of a radioactive substance follows a continuous exponential decay model, with a decay rate…
Q: In each case, determine whether or not the lines have a single point of intersection. If they do,…
Q: The following equilibrium pressures were observed at a certain temperature for the reaction N₂ (9) +…
Q: The ribosomes of eukaryotic cells are found: a. On rough endoplasmic reticulum and in the cytoplasm…
Q: reaction should occur in each of these?
Q: Question 23 Which process is not an example of post-transcriptional control of gene expression:…
Q: Wrett purchases a new four-wheeler with a loan from his bank. The bank requires that he use his car,…
Q: 10) Why do aerobic cells need oxygen? Where exactly is the oxygen needed?
Q: How do you calculate the break-even point in sales? Contribution margin + fixed costs Fixed costs…
Q: A female is heterozygous for an X-linked gene.  If nondisjunction happens for the sex chromosomes…
Q: 7) A halophile (salt-loving) microbe can live in high salt environments because.... a) It has a very…
Q: Which of the following refers to an increase in mutations due to defects in proteins needed to…
Q: Suppose you purchase eight call contracts on Macron Technology stock. The strike price is $60 and…
Q: 4.08 ¡Î1.02↑ E E 2.54 H H 1.02 Note: 1.67 = EXON = INTRON E 10.8 kbp 3.94 3.66 E = EcoRI site H =…
Q: Suppose x¡ i = 1, ..., n is distributed according to the distribution with density exp(-|x₁ − μ|)…
Q: What statistical test to use?  A researcher is interested in whether self-proclaimed "cat people"…
Q: Complete the Lewis structures for COCI₂ and SOCI₂ using the skeletal structure shown below, being…