From: Peter Perkins on 6 May 2010 09:14 On 5/6/2010 5:54 AM, DSPtree wrote: > clear all; > n=10000; > x=randn(1,n); > y=randn(1,n); > subplot(221);bar(x);subplot(222);bar(y); > z=sqrt(-2*log(x))*cos(2*pi*y'); > t=hist(z,100); > subplot(212);plot(t); Consider the following: 1) "Given 2 independent uniform random variables X,Y" Check your code, and type "help rand" and "help randn" 2) "For each sample of X and Y, compute Z= g(X,Y)" Type "help times", and "help mtimes", and then check your code. In particular, what should the size of z be, and what is it? What does the transpose on y do (hint: that's why your code does not give you an error that would help you figure out where you're going wrong)? 3) "Draw a histogram over the resulting samples in Z" What does "plot(t)" do? It does not create a histogram. Hope this helps.
From: DSPtree on 6 May 2010 12:05 Thank you so much for the help. x=randn(1,10000); y=randn(1,10000); z=sqrt(-2*log(x)).*cos(2*pi*y); hist(z,100); I have made it shorter again.But still the shape of 'z' doesn't look familiar. So I guess I still have something wrong with this small program.. Well I m just a starter in matlab. expecting support.
First
|
Prev
|
Pages: 1 2 Prev: variable dependency debugging tool Next: Moving columns below other columns, in a matrix |