COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### uniform random variable

• Email
• Follow

```Given 2 independent uniform random variables X,Y = U [0,1], consider the random variables Z = g (X,Y) for g (x,y) = sqrt (-2ln(x) ). cos(2piy)..This is the condition.So I need to go for matlab program as the analytic method is tough

1 - 10,000 uniformly distributed random samples for X and Y
2 - For each sample of X and Y, compute Z= g(X,Y)
3 - Draw a histogram over the resulting samples in Z
4 - Estimate the moments mZ for n = 1,2....6.
```
 0

See related articles to this posting

```DSPtree <paulscot45@yahoo.com> wrote in message <2024364947.79076.1273099076053.JavaMail.root@gallium.mathforum.org>...
> Given 2 independent uniform random variables X,Y = U [0,1], consider the random variables Z = g (X,Y) for g (x,y) = sqrt (-2ln(x) ). cos(2piy)..This is the condition.So I need to go for matlab program as the analytic method is tough
>
> 1 - 10,000 uniformly distributed random samples for X and Y
> 2 - For each sample of X and Y, compute Z= g(X,Y)
> 3 - Draw a histogram over the resulting samples in Z
> 4 - Estimate the moments mZ for n = 1,2....6.

Surely you have tried something? If not, why not?

John
```
 0

```DSPtree wrote:
> Given 2 independent uniform random variables X,Y = U [0,1], consider the random variables Z = g (X,Y) for g (x,y) = sqrt (-2ln(x) ). cos(2piy)..This is the condition.So I need to go for matlab program as the analytic method is tough
>
> 1 - 10,000 uniformly distributed random samples for X and Y
> 2 - For each sample of X and Y, compute Z= g(X,Y)
> 3 - Draw a histogram over the resulting samples in Z
> 4 - Estimate the moments mZ for n = 1,2....6.

Okay, go ahead, we give you permission to write such a program. If you
should happen to come up with a _specific_ Matlab question, then if you
indicate what you are having trouble with, we may be able to assist you.
```
 0

```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);

This is what i have done till now. But I am not sure whether i could take z like that and plot it.
```
 0

```the plot shows a normal distribution i guess. shall i have to take some arbitary mean and sigma . this  output looks little weird.
```
 0

```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

3) "Draw a histogram over the resulting samples in Z"

What does "plot(t)" do?  It does not create a histogram.

Hope this helps.
```
 0

```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.
```
 0

6 Replies
628 Views

Similar Articles

12/6/2013 8:13:54 AM
page loaded in 45180 ms. (0)

Similar Artilces:

design timelines
hi-- i'm doing a work on a large system and while i have no problems getting intot he bit and pieces of code, i'm finding it much more difficult to put together the "larger picture". i was hoping that it would sort of form organizically as I worked on variouis nuts and bolts, but even if plausible, i releaize that it's goinn to take too much time. so i'm thinking that i am going to have to just sit down for a spell and follow the systems execution thru, line by line. in doing so , it's seems a waste to be the only one who benefits from my drudger --it should be

vectorizing if loop
G'day, I have the following matrix... Beta = [52 52 52 52 60 52 40 24 32 44]; yB = zeros(1,length(Beta)).'; for i = 1:length(Beta) if Beta>0 & Beta<10 yB(i)=1; elseif Beta>10 & Beta<63 yB(i)=cos((Beta-10)*pi()/180); elseif Beta>63 yB(i)=0.63; end end For starters, the if loop doesn't do anything (other than creating the initial matrix) and it is not clear to me why. I guess one approach to vectorizing the code is to eliminate the first and third if statements and use the find function instead. Howev

genrate uniform random variable from a set
Is there away to genrate random number from a set of numbers for example random number from the set {1,3,4,6,9} "Namo " <namo1983@hotmail.com> wrote in message news:hq7br0\$mll\$1@fred.mathworks.com... > Is there away to genrate random number from a set of numbers > > for example random number from the set {1,3,4,6,9} > Use RANDI to generate a random integer between 1 and NUMEL of the set, then use that random integer as an index. myset = [1 3 4 6 9]; indices = randi([1 numel(myset)], 10, 10); values = myset(indices) -- Steve Lord slord@mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ "Namo " <namo1983@hotmail.com> wrote in message <hq7br0\$mll\$1@fred.mathworks.com>... > Is there away to genrate random number from a set of numbers > > for example > random number from the set {1,3,4,6,9} one of the many solutions s={1,3,4,6,9}; % <- set n=5; % <- # of randomly chosen elements of S ix=ceil(5*rand(1,n)); r=[s{ix}] % r = 9 6 3 6 6 % <- current state of RAND... us

Form Validation, variable problem
Hi, i use phpdev and I have a stupid problem. I use a form and I want to pass a variable (name) from one page to another (overview.php). ......... <form method="post" action="overview.php"> <table width="100%" border="0"> <tr> <td width="24%">Name : </td> <td width="76%"><input type="text" name="name"></td> </tr> <tr> ................ when I fill in something, the name variable will be passed when i press the submit button, but the strange thing is, that it doens't pass anything to overview.php !!!! a piece of overview.php: ...... <td width="18%">Naam van het bedrijf: </td> <td width="82%"><?php echo \$naam; ?></td> ...... so it is very easy stuff I want (pass a variable), but in phpdev (have tried every version i found on the net) i doesn't work, but in my webserver (www.xyz.be) it works!!!! it give the good value through... has anybody has a solution? because i need phpdev to work (i go on holiday a need to finish some stuff) thx geronimo

Random Oblivion thoughts .. and bug(let)s
;>up - has anyone? In MW it was fairly trivial to get +5 on all 3 >>attributes every time, if you wanted to train too much. > >I'm not sure how much you have to level a minor skill to get +5 but its not >hard to do. I levelled to 15 and found that light armour had only got +3. I >was deliberately trying to raise my Speed so I went to a trainer in Bravil and >trained 3 times. This got me +5. OK, It's hard to do =without training=. And early on training is pretty expensive compared to the loot you find, unless you go training random stuff you don't really