{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# solution01 - while that for α = 128 should oscillate...

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

Solutions to Homework 01 1. One possible program: #include <stdio.h> #include <stdlib.h> #include <math.h> main(int argc, char **argv) { int i, alpha, old, new; if (argc != 3) { printf("Too few arguments \n"); printf("Usage: %s <alpha> <X_0> ", argv[0]); exit(1); } alpha = atoi(argv[2]); old = atoi(argv[3]); for (i=0; i<1000; i++) { new = (alpha*old)%8191; printf("%d \n", new); old = new; } } The main thing to worry about is the line new = (alpha*old)%8191 . Also note that the pseudo random nubers that are generated may not have all the numbers between 0-8191. Also there should be sequence of length around 13 which keeps repeating, for α = 128. The exact sequence depends on the value of α and X (0). 1

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

View Full Document
2. < X > n = 1 n n j =1 X ( j ) = 1 n X ( n ) + n - 1 j =1 X ( j ) = 1 n X ( n ) + ( n - 1) 1 n - 1 n - 1 j =1 X ( j ) = 1 n { X ( n ) + ( n - 1) < X > n - 1 } = < X > n - 1 + X ( n ) - < X > n - 1 n 3. The students can take the sequence they generate and put it in any plotting software they like. The final value of the average for α = 126 should converge to around 4096
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: while that for α = 128 should oscillate around. Note that the oscillation for the case of α = 128 repeat every 13 values around a value close to 1260. The general shape of the plots is given in ±igure 1. 2 1000 2000 3000 4000 5000 6000 7000 8000 100 200 300 400 500 600 700 800 900 1000 "ave128" 1000 2000 3000 4000 5000 6000 7000 8000 100 200 300 400 500 600 700 800 900 1000 "ave126" (a) α = 128 (b) α = 126 1100 1150 1200 1250 1300 1350 1400 1450 1500 100 200 300 400 500 600 700 800 900 1000 "ave128" 3000 3500 4000 4500 5000 100 200 300 400 500 600 700 800 900 1000 "ave126" (a) α = 128 (b) α = 126 Figure 1: Averages of the random numbers generated for α = 128 and α = 126. The ±gures on the bottom row are zoomed versions of the ±gures on top in order to illustrate the oscillations. 3...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

solution01 - while that for α = 128 should oscillate...

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

View Full Document
Ask a homework question - tutors are online