Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: User problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24062] Re: User problem
  • From: "David Bailey" <db at salford-software.com>
  • Date: Thu, 22 Jun 2000 01:01:54 -0400 (EDT)
  • Organization: University of Salford, Salford, Manchester, UK
  • References: <8ihuik$lcl@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

joseph <joseph468 at yahoo.com> wrote in message
news:8ihuik$lcl at smc.vnet.net...
> Can anyone help:
> I am trying to contstruct a table of random integers
> between 1 and 4. I'd like to vary the number of
> elements in the table from time to time. The
> contruction that I use in Mathematica is as follows:
>
> genome = Table[i = Random[Integer, {1, 4}], {i, 249}]
>
> The problem with this is as follows: the above
> generates tables of varying length up to and including
> 249 elements.  However, when I try to generate any
> table containing more than 249 elements, I get the
> following error message on my screen:
>
> This program has performed an illegal operation and
> will be shut down.  If the problem persists please
> contact the vendor.

I am not quite sure whether you want the length of the list to be random
with some upper limit, or if you want to specify the length of the string
exactly. The easiest approach is to define genome as a function and use:

genome[k_]:=Table[ Random[Integer, {1, 4}], { Random[Integer, {1, k}]}]

if you want randomly varying list lengths. If you want fixed length lists
try:

genome[k_]:=Table[Random[Integer,{1,4}],{k}]

If you obtain a viable organism this way it will indicate that the Random
function is not so good after all!

As you had coded the problem you had effectively assigned a value to the
loop variable. It is interesting that Mathematica did not give an error even
for values below 250. I guess Mathematica must change its algorithm at this
point because:

Table[i = 42, {i, 249}]

'works' but:

Table[i = 42, {i, 250}]

blows the kernel away in exactly the way you describe!

David Bailey
Salford Software






  • Prev by Date: Re: Re:two dimensional distribution
  • Next by Date: RE: Resources for high school student?
  • Previous by thread: RE: Re: User problem
  • Next by thread: Re: RE: Re: User problem