random number including 1 - i.e. [0,1]

Paul McGuire ptmcg at austin.rr.com
Wed Jun 10 15:40:58 CEST 2009


On Jun 9, 11:23 pm, Esmail <ebo... at hotmail.com> wrote:
> Here is part of the specification of an algorithm I'm implementing that
> shows the reason for my original query:
>
> vid = w * vid + c1 * rand( ) * ( pid – xid ) + c2 * Rand( ) * (pgd –xid ) (1a)
>
> xid = xid + vid (1b)
>
> where c1 and c2 are two positive constants,
> rand() and Rand() are two random functions in the range [0,1],
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> and w is the inertia weight.

It is entirely possible that the documentation you have for the
original rand() and Rand() functions have misstated their range.  In
my experience, rand() functions that I have worked with have always
been [0,1).

-- Paul



More information about the Python-list mailing list