help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difference between normal_rnd (m,v, n,n) and randn (n)


From: David Bateman
Subject: Re: Difference between normal_rnd (m,v, n,n) and randn (n)
Date: Fri, 5 Mar 2004 10:30:14 +0100
User-agent: Mutt/1.4.1i

If you are going to use two uniform variates for each variate produced
then you are going to be at least twice as slow as "rand". It distribution
is rather simple to implement with a ziggurat method similar to that used
in randn and rande in octave-forge.... This should give you nearly the
same speed as the basic rand calculations.. Note sure this is worth the
effort though..

Cheers
David



Daprès Quentin Spencer <address@hidden> (le 04/03/2004):
> Henry F. Mollet wrote:
> 
> >I have to check what exactly people say when they say that they use a
> >triangular distribution. I surmise that the probability density function in
> >the range [0,1] increases linearly from some value at 0 to a maximum at an
> >intermediate value (might be in the middle of the range) and then decreases
> >linearly to some value at 1.  I'll try to modify what you gave below to get
> >something that looks like a triangle. Thanks.
> >Henry
> > 
> >
> OK, this kind of distribution can be generated from the summation of two 
> uniform random variables. Since the summation of two random variables 
> has a pdf that is the convolution of the pdfs of the two variables, the 
> convolution of uniform [0,1] with itself is f(x) = {x,  0<x<1 ; 2-x,  
> 1<x<2 ; 0 otherwise }, which is the triangular function you describe, 
> centered at 1 rather than 1/2. To test this, try:
> 
> x = rand(2,N);
> hist(sum(x));
> 
> You could multiply the result by a scale factor of 0.5 if you wanted the 
> values in the range [0,1], for example.
> 
> Hope this helps.
> 
> -Quentin
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------

-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]