       Re: issue generating table of random numbers

• To: mathgroup at smc.vnet.net
• Subject: [mg81923] Re: issue generating table of random numbers
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sat, 6 Oct 2007 04:50:09 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• 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
>

FWIW,

I witness the same behavior with Mathematica 6.0.1 for Windows. Four by
four matrices are generated up to 249. Above, they are flattened. In
this case, the packed array technology seems to interfere in some
unexpected way(s). (Seems to be a good candidate for a bug report :-)

In:= matrix = Table[RandomChoice[{-1, 1}, {4, 4}], {249}];
First@matrix
matrix // Developer`PackedArrayQ

Out= {{1, -1, 1, 1}, {1, 1, -1, 1}, {-1, 1, 1, 1}, {-1, -1, -1,
1}}

Out= False

In:= matrix = Table[RandomChoice[{-1, 1}, {4, 4}], {250}];
First@matrix
matrix // Developer`PackedArrayQ

Out= {{1, 1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1}}

Out= True

Regards,
--
Jean-Marc

```

• Prev by Date: Re: Fast alternative to Nest[.] or NestList[.]? (version 6.0)
• Next by Date: Re: NMinimize
• Previous by thread: Re: issue generating table of random numbers