help-octave
[Top][All Lists]
Advanced

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

Re: restoring state of rand()


From: David Bateman
Subject: Re: restoring state of rand()
Date: Fri, 15 Oct 2004 12:05:35 +0200
User-agent: Mutt/1.4.1i

This is a bug. The problem is that you requested the state before it
was initialized, and so the vector v contains all zeros.. Try and

rand(3,1)
v = rand("state");
rand(3,1)
rand("state",v);
rand(3,1)

and you'll see what I mean... I just committed a patch to fix this..

D.

According to Michael Creel <address@hidden> (on 10/15/04):
> Hello,
> 
> "help rand" tells me that
> 
> <quote>
> You can query the state of the random number generator using the
> form
>           v = rand ("state")
> This returns a column vector V of length 625. Later, you can
> restore the random number generator to the state V using the form
>           rand ("state", v)
> </quote>
> 
> but my mileage varies:
> 
> octave:1> help rand
> octave:2> v = rand("state");
> octave:3> rand(3,1)
> ans =
> 
>   0.82058
>   0.29780
>   0.98109
> 
> octave:4> rand("state",v);
> octave:5> rand(3,1)
> ans =
> 
>    4.4409e-17
>    4.4409e-17
>    4.4409e-17
> 
> Can anyone help me out? I'm using octave-forge compiled against octave 2.1.57
> 
> Michael
> 
> 
> 
> -------------------------------------------------------------
> 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]