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

MathGroup Archive 2007

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

Search the Archive

Re: Beginner--Help on Listing Values

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74965] Re: Beginner--Help on Listing Values
  • From: "dimitris" <dimmechan at yahoo.com>
  • Date: Fri, 13 Apr 2007 01:59:13 -0400 (EDT)
  • References: <evhtp3$2tq$1@smc.vnet.net>

Hello.

Clear["Global`*"]

rand[h:Integer | Real, {(a_)?NumberQ, (b_)?NumberQ}, d_Integer] := (#1/
Tr[#1] & )@Table[Random[h, {a, b}], {d}]

ls1 = rand[Integer, {-30, 30}, 20]
ls2 = rand[Real, {-10, 10}, 30]

{13/152, 5/38, 5/152, 17/152, -(13/76), -(1/19), 3/38, 3/152, 17/152,
11/152, 5/152, 25/152, 7/152, 1/38, 0, -(13/76), 25/152, 11/152, 1/8,
9/76}

{0.160557,0.192586,-0.0993901,-0.179493,0.390724,-0.124995,-0.487228,-0.\
110376,-0.444609,-0.0932739,0.0812527,-0.470073,0.130112,-0.0265495,-0.1212=
24,\
-0.188016,0.10593,0.100737,0.399792,-0.469098,-0.0471127,0.416487,0.437451,=
0=2E\
481372,0.312831,-0.296601,0.01634,0.140363,0.442609,0.348895}

(*Test*)

Tr@ls1
Tr@ls2

1
1=2E

Dimitris

where
=CF/=C7 m.lungay at gmail.com =DD=E3=F1=E1=F8=E5:
> I need to create a list of probability values for a certain random variab=
le X. It is very difficult if i keep on enumerating the entries especially =
when the length required is large, say the list is of length 100. Maybe the=
re is some way where I could generate the entries in a random manner. There=
 is a code Random[], but how could I implement it in a List manner so that =
the sum of the results must be 1. Please help!
>
>
>
> Link to the forum page for this post:
> http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName==
Special:Forum_ViewTopic&pid=17333#p17333
> Posted through http://www.mathematica-users.org [[postId=17333]]



  • Prev by Date: Re: comments in import files
  • Next by Date: Re: Re: Optimal variable selection in multiple linear regression ?
  • Previous by thread: Re: Beginner--Help on Listing Values
  • Next by thread: Marking pivot elements in a matrix?