Re: issue generating table of random numbers
- To: mathgroup at smc.vnet.net
- Subject: [mg81904] Re: issue generating table of random numbers
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Sat, 6 Oct 2007 04:40:22 -0400 (EDT)
- References: <fe4v33$1kh$1@smc.vnet.net>
John Molina wrote: > Hi, I'm running Mathematica 6 on OsX (10.4) and have been experiencing difficulties generating a table of random numbers (a table of random matrices actually). > matrix = Table[RandomChoice[{-1, 1}, {4, 4}], {250}] > for a table size less than 250 it seems to work fine but for larger sizes mathematica is flattening out the lists: > matrix[[i]] = {-1,1,1,-1} > and not > = {{-1,1},{1,-1}} > As far as I can tell this is only happening with the RandomChoice command (RandomInteger and RandomReal work fine). Does anyone know what is happening? is this a bug? > thanks > Wow, this looks like a nasty bug to me. It must be some kind of trouble with packed arrays, since Table switches to a packed array representation at size 250: In[1]:= <<Developer` In[2]:= PackedArrayQ[Table[1, {249}]] Out[2]= False In[3]:= PackedArrayQ[Table[1, {250}]] Out[3]= True As a workaround you could use RandomChoice[{-1, 1}, {250, 4, 4}] -- Szabolcs