MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: RandomReal gets stuck

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100290] Re: RandomReal gets stuck
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Sun, 31 May 2009 06:34:12 -0400 (EDT)
  • References: <gvq0eu$n31$1@smc.vnet.net>

Hi Bas,

I can confirm this bug.

Executing an even simpler version, namely

Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]];

will also set the random generator to a fixed starting point. The
number 31 is crucial, as lower values do not appear to cause the bug,
while higher values do. Changing Plus to Times appears to prevent the
bug.

In[394]:= Table[
 Maximize[Plus @@ Table[y[i], {i, 31}], Table[y[i], {i, 31}]];
 RandomReal[],
 {20}
 ]

During evaluation of In[394]:= Maximize::natt: The maximum is not
attained at any point satisfying the given constraints.  >>

Out[394]= {0.455719, 0.455719, 0.455719, 0.455719, 0.455719, \
0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719,
\
0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719, 0.455719,
\
0.455719}

This is very nasty, as a lot of people critically depend on random
functions to be random. I would urge you to report this to wolfram
support.


Cheers -- Sjoerd

On May 30, 3:00 am, Bas Straatman <bastr... at ucalgary.ca> wrote:
> Hi,
>
> For a simulation of a stochastic process I am making use of RandomReal.
> I noticed that at some point during the simulation the output of
> RandomReal[] becomes fixed. For some reason, totally beyond my
> comprehension, every time after I execute an optimization the
> RandomReal[] generates the same series of random numbers:
>
> In[217]:= optimalactivity
>
> Out[217]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0, \
> 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
> 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
>
> In[218]:= RandomReal[]
>
> Out[218]= 0.455719
>
> In[219]:= RandomReal[]
>
> Out[219]= 0.977826
>
> In[220]:= RandomReal[]
>
> Out[220]= 0.943215
>
> In[221]:= RandomReal[]
>
> Out[221]= 0.962216
>
> In[222]:= RandomReal[]
>
> Out[222]= 0.302348
>
> In[223]:= optimalactivity
>
> Out[223]= {24, 336/25, 616/25, 32/5, 28/5, 76/25, 4, 8, 8, 4/5, 0, 0, \
> 0, 0, 0, 4/5, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
> 0, 0, 0, 0, 0, 12, 28, 80, 0, 104/3, 0, 234/125, 0, 0, 0, 0, 4, 0, 0, \
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
>
> In[224]:= RandomReal[]
>
> Out[224]= 0.455719
>
> In[225]:= RandomReal[]
>
> Out[225]= 0.977826
>
> In[226]:= RandomReal[]
>
> Out[226]= 0.943215
>
> In[227]:= RandomReal[]
>
> Out[227]= 0.962216
>
> In[228]:= RandomReal[]
>
> Out[228]= 0.302348
>
> optimalactivity simpy calculates an optimum allocation of resources:
>
> optimalactivity := Table[y[i], {i, Length[inputmatrix]}] /.    Maxi=
mize[
>       Plus @@ (Table[y[i], {i, Length[inputmatrix]}].(outputmatrix =
 -
> inputmatrix))[[consumables - 2]], CONDITIONS ,
> Table[y[i], {i, Length[inputmatrix]}]][[2]]
>
> There is no SeedRandom[] anywhere to be found.
>
> Any ideas how this is possible? Thanks.
>
> Bas Straatman



  • Prev by Date: Re: problem writing debugging utility function
  • Previous by thread: Re: RandomReal gets stuck
  • Next by thread: problem writing debugging utility function