octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #30399] DLD can change rand distribution in oc


From: julien javaloyes
Subject: [Octave-bug-tracker] [bug #30399] DLD can change rand distribution in octave interpreter
Date: Fri, 09 Jul 2010 13:37:31 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6

URL:
  <http://savannah.gnu.org/bugs/?30399>

                 Summary: DLD can change rand distribution in octave
interpreter
                 Project: GNU Octave
            Submitted by: javaloye
            Submitted on: Fri 09 Jul 2010 01:37:30 PM GMT
                Category: Libraries
                Severity: 3 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: julien
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.2.3
        Operating System: GNU/Linux

    _______________________________________________________

Details:


in octave interpreter "rand" gives uniform random numbers while randn gives
gaussian random numbers. 
Indeed, calling 
--rand ("state", [1:625]); rand
gives uniform numbers.

However, after calling within the interpreter a dld function that changes the
mode of the random number generator like below

--dummyfunc

subsequent calls to 
--rand ("state", [1:625]); rand
produces gaussian and not anymore uniform random numbers.

--This bug does not depend on the seed of the generator, i.e. replace [1:625]
by anything integer.

Fixing is easy as one simply need to reset the mode of the generator before
exiting the dld function. 
However, I think that a dld function should not be able to "swap"  the rand
and the randn functions in octave interpreter.

dld function compiled with mkoctfile


#include <octave/oct.h>
#include <octave/oct-rand.h> 

DEFUN_DLD (dummyfunc,args,nargout,"")
{
 
octave_rand::distribution("normal");    // put octave random generator to
gaussian mode

// do something 

//octave_rand::distribution("uniform"); // put the generator back to uniform
mode for correct behavior

 return  octave_value_list();        
 //----------------------------------------------------------//
}







    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?30399>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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