Assignment:
1. Complete the code for arbitrary, A, ωet, and N (i.e. the values of A, and N are entered ea the first 3 lines of the code).
2. Test when A = 1 and = 0 for N=10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, and 100000. What does this say about N?
3. Rerun part 2 when ,ωet = .1, 1, 10 and 100. Are your results what you expect? Why or why not?
4. You can also nee this method to calculate the autocorrelation function, Rx(t1,t2). Let
Rx(t1,t2) = A cos2(ωet1 + θ) cos(ωet2 +θ)
Modify your cede to calculate the autocorrelation. Test your modified code when A = 1, ωet1 = .1, and ωet2= .4 for N=10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000 and 100000. Compare your answer to the exact one, equation. Do they agree? Why or Why not?
The purpose of this assignment is to investigate a Monte Carlo type Simulation for an ensemble average.
We can perform a Mende Carlo simulation to calculate the ensemble average of a random process. Consider the Random Process as in Example
x(t) = A cos(ωet + θ)
where θ is a uniformly distributed random variable in the range (0, 2Π). To calculate the ensemble average x(t), we need to calculate a 1-dim array of uniformly distributed random variables θ, then calculate x(t) for each value and sum. If we generate enough variables, the sum will converge to the integral.
To generate a 1 dimensional array of uniformly distributed random num¬bum over the range (0,1) in Matlab use the rand(M,N) function which gen¬erates uniformly distributed random numbers.
For example, to generate 10000 uniformly distributed random numbers we can use
N=10000;
θ= rend(1,N) ;
To scale the random numbers from 0 to 2Π, just multiply by 2Π.
Then choose a value for ωet, then calculate the individual values of x(t) and sum (most likely using the same techniques as in the previous assignment) and divide by N.