MathGroup Archive 2005

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

Search the Archive

Re: simple question about random

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58927] Re: [mg58894] simple question about random
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 24 Jul 2005 01:21:48 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Define a routine...

nRandom[n_] := Table[Random[Integer, {0, 10}], {n}]

nRandom[6]
{5, 6, 0, 3, 7, 3}

or...

nRandom[n_] := Array[Random[Integer, {0, 10}] &, n]

nRandom[6]
{5, 8, 3, 4, 2, 5}

or just use on a one time basis...

Table[Random[Integer, {0, 10}], {6}]
{6, 3, 8, 1, 2, 6}

The humble Table command is very useful and much better than For or Do
(which wouldn't even work in this case.)

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Mazuego [mailto:mazuego at yahoo.com]
To: mathgroup at smc.vnet.net


Hi all... The built-in function "Random" gives a random number in a chosen
range. How can I have, for example, 6 random numbers with a single
instruction? Thank you very much for your answers, and forgive me for the
simple question, but I'm new in Mathematica...



  • Prev by Date: Setting gridlines thickness in Plot
  • Next by Date: rotate frametick labels
  • Previous by thread: Re: simple question about random
  • Next by thread: Re: simple question about random