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: Quentin Spencer
Subject: Re: Difference between normal_rnd (m,v, n,n) and randn (n)
Date: Thu, 04 Mar 2004 16:01:54 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040116

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



reply via email to

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