MathGroup Archive 2002

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

Search the Archive

RE: simple program: help, please!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34485] RE: [mg34462] simple program: help, please!
  • From: "tgarza01 at prodigy.net.mx" <tgarza01 at prodigy.net.mx>
  • Date: Thu, 23 May 2002 03:32:31 -0400 (EDT)
  • Reply-to: tgarza01 at prodigy.net.mx
  • Sender: owner-wri-mathgroup at wolfram.com

You have a funny-looking problem, but the solution is quite simple. Load the Statistics` package:

In[1]:=
<<Statistics`

Then define the distribution you want to sample from (in this case, the exponential distribution with parameter = 1).

In[2]:=
dexp=ExponentialDistribution[1];

The "program" you want is as simple as this (one of many possibilities):

In[3]:=
result={};Do[vo=Sort[RandomArray[dexp,50]];
  AppendTo[result,{i,Plus@@Take[vo,30]/i,vo}],{i,1,500}]

You now evaluate result and get the answer you are looking for in 2.5 seconds: 500 rows, and in each of them the index for the i-th iteration; the quotient s/i, and the vector vo.

In[4]:=
result

(output omitted).

Tomas Garza
Mexico City

Original Message:
-----------------
From: _MarioLatens mario.lat at libero.it
To: mathgroup at smc.vnet.net
Subject: [mg34485] [mg34462] simple program: help, please!


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?

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .



  • Prev by Date: Re: Plotting mulitple lists on one log plot
  • Next by Date: Re: generating random number
  • Previous by thread: Re: simple program: help, please!
  • Next by thread: Q: Strange Mathematica 3.0.1.1 Behaviour