Re: simple program: help, please!
- To: mathgroup at smc.vnet.net
- Subject: [mg34472] Re: simple program: help, please!
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 23 May 2002 03:32:12 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <acffm8$rs5$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, what is "i" ? Needs["Statistics`ContinuousDistributions`"] FirstNSum[lambda_?NumericQ, n_Integer] := Module[{sample, sum}, sample = Sort[Table[Random[ExponentialDistribution[lambda]], {n}]]; sum = Plus @@ Take[sample, 30]; {sum/i, sample[[Round[3n/5]]]} ] Table[FirstNSum[1, 50], {100}] ? Regards Jens _MarioLatens wrote: > > I have to do something like this: I don't know mathematica language but I > think it can do that... > > for i=1 to 500 > ( > 1) get 50 nubers random from 1 to 100. (to be onest I need exponential > distribution) and put it in a vector 'v' > > 2) order this vector ('v') : vo=order_vector (v) > > 3) take the 30th elemente : e=vo[30] > > 4) calculate sum of first 30 elements of vo : for(j=1 to 30) s=s+vo[j] > > 5) calculate d=s/i; > > 6) print d, print the vector vo. > > ) > > I don't know mathematica very well and I have to manipulate data in a > little time so I ask help you: how can I write this programs? > > Thank you in advance, Mario. > > P.S. where can I find nice manual on internet for programming whith > mathematica?